Created
November 1, 2012 19:51
-
-
Save unlight/3996017 to your computer and use it in GitHub Desktop.
Reverse words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <conio.h> | |
| #include <string.h> | |
| int main() | |
| { | |
| char String[255]; | |
| char* Words[50]; | |
| char* Pchar; | |
| char Delimeter[] = " .,!"; | |
| int Index = 0; | |
| if (strlen(String) <= 2) { | |
| printf("String: "); | |
| gets(String); | |
| } else { | |
| printf("String: %s\n", String); | |
| } | |
| Pchar = strtok(String, Delimeter); | |
| while (Pchar != NULL) { | |
| Words[Index] = Pchar; | |
| Pchar = strtok(NULL, Delimeter); | |
| Index++; | |
| } | |
| while (Index > 0) { | |
| Index--; | |
| printf("'%s'", Words[Index]); | |
| if (Index != 0) printf(", "); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment