Thread: late night coding

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751

    late night coding

    As the title suggest i'm coding at late o'clock over here and My code just hangs. I'm sure its something simple but I'd like to get it before bed.
    thanks.
    Code:
    /* my getWord.c 
    GetWord reads characters from stdin up until the first space. it stores it in its
    argument a char * and appends a '\n' then returns the word */
    #include <stdio.h>
    #include <string.h>
    #define STOP ' '
    #define SIZE 100
    
    char *GetWord(char *);
    int main(void){
        char store[SIZE];
        
       char *word = GetWord(store);
        printf("The word is %s", word);
        getchar();
        return 0;
    }
    
    char *GetWord(char vault[]){
        int ch,ndx=0;
        while( (ch = getchar()) !=STOP || ch !=EOF){
             vault[ndx] = ch;
            ndx+=1;
        }
        vault[ndx] = '\0';
        while(getchar() !='\n');
        return vault;
    }
    Last edited by caroundw5h; 09-01-2004 at 10:46 PM.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectShow code - long night of coding
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 03-27-2006, 10:50 AM
  2. Late night part 2
    By caroundw5h in forum C Programming
    Replies: 5
    Last Post: 09-09-2004, 10:07 AM
  3. Good times, late at night
    By prog-bman in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-15-2004, 09:02 AM
  4. late night coding
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 01-08-2004, 09:23 PM
  5. friday night coding with mind numbing music
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-13-2002, 05:17 PM