eof « fgets « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » fgets » eof 

1. fgets() and EOF    cboard.cprogramming.com

#include #include #include #define MAX 100 void reverse (char s[]); int main (int argc, char *argv[]) { char mystring[MAX]; printf("Please enter a string of characters.\nEnter quit when done.\n"); fgets(mystring,MAX,stdin); reverse(mystring); return 0; } void reverse (char mystring[]) { int x; x=strlen(mystring); for(x=strlen(mystring); x>=0; x--) { printf("%c", mystring[x]); } printf("\n"); }

2. Check for EOF when using fgets    cboard.cprogramming.com

3. fgets and EOF    cboard.cprogramming.com

Alright, so if I use fgets how do I tell it to keep reading lines in until it reaches the end of file ?? I keep getting runtime errors if I put != EOF ... is != NULL equivalent?? Also, if I use fgets how do I search through as I am reading it in for a specific character?? I've tried ...

4. Checking EOF while using fgets()... Confused.    daniweb.com

// Read into DATAFILE and get Stock Info file = fopen(argv[1], "r"); // fgets(s, MAX_BUFF, file); // printf("Printing s from datafile: %s\n", s); while(1) { fgets(s, MAX_BUFF, file); printf("Printing s: %s\n", s); if(ferror(file)) { break; } if(s == NULL) { break; } if(strncmp(s, stock_id, 5) == 0) { printf("Found the stock in %s!\n", argv[1]); break; } else printf("Cannot find the stock ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.