Created
September 15, 2010 00:40
-
-
Save lsparrish/580046 to your computer and use it in GitHub Desktop.
playing around with c
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> | |
| char* listen(); | |
| int process(); | |
| int strcmp(); | |
| int output(); | |
| int main() { | |
| char *str; | |
| while (strcmp(str,"bye\n") != 0){ | |
| str=listen(); | |
| process(str); | |
| } | |
| return 0; | |
| } | |
| char str [1024]; | |
| char* listen(){ | |
| char *p; p=str; /* initialize pointer */ | |
| /* this increments the pointer after doing getc | |
| then compares to see if it is a newline char: */ | |
| while((*p++=(getc(stdin)))!='\n'); | |
| *p=0; /* make sure it knows where to end the string */ | |
| return str; | |
| } | |
| int process(char *str){ | |
| output(str); | |
| return 0; | |
| } | |
| int output(char *str){ | |
| char *p; p=str; /* initialize pointer */ | |
| while((putc(*p++,stdout))!=0); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment