Thread: read string from file until EOF

  1. #1
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110

    read string from file until EOF

    Code:
    int len;
    	char ant[size];
    do{
    fgets(ant,size,file1);
    			for(len=0;len<size;len++){
    if(ant[len]=='a'){fprintf(file2,"[*]");}
    }
    while(ant!=EOF);
    i know this wont work because the compiler says cannot convert char to int or whatsoever
    but ive tried to do it with one character at the time but didnt worked as well
    so wath im trying to do is read a string from file1 and then i say if an 'a' is in the string ant then it has to fprintf[*] in file 2

    now this works but it oly works for the first line of file1 so i was thinking ill just add do while(ant!=EOF) but it seems that that wont work ....
    any suggestions would be welcome

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    thx ...now i just have to make sure
    when in file1 a new line starts it also starts a new line in file 2
    anyway thx (never thought it was that easy i even think i tried do while(ant!=NULL) once ....)

  3. #3
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    well i tried the *p thing butive figured out that doesnt works
    because im not trying to make an a into an[*] but im trying to make a whole string like lamb into [}][*][{][£]
    but ill figure out how to do it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM