Thread: question

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    13

    question

    Hi
    I need to know how to read ASCII data in words to search for a string of 5 letter words in a text file. Anyone knw how to do it? I'm going in circles here . Here's a portion of my code

    FILE *fp ;
    SIZE = 5;

    str = (char *) malloc(sizeof(char)*SIZE);
    strstart = str ;
    temp = (char *) malloc(sizeof(char)*5);


    if((fp = fopen("word.txt","rb")) == NULL)
    printf("file cannot be opened\n");

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You'd be better off reading a line at a time into a buffer and then scanning it for the word you want.

    fgets()
    sscanf()
    strstr()

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM