Hello to all,
I just want to know which characters represent EOF.
I am using TURBO C in WINDOWS.
Using code when I printed it shows -1 but in the output screen when I use it, it does not seem to be EOF.
Thanks for your support.
Hello to all,
I just want to know which characters represent EOF.
I am using TURBO C in WINDOWS.
Using code when I printed it shows -1 but in the output screen when I use it, it does not seem to be EOF.
Thanks for your support.
EOF cannot be accurately represented by a char. Use an int to read characters if you need to test for EOF.
Quzah.
Hope is the first step on the road to disappointment.
It doesn't matter. Just use EOF when you want to check against EOF. There's no need to ever, ever, ever know what EOF is, because the standard doesn't say exactly what it'll be.
But yeah, -1 is a common value implementors use
If you understand what you're doing, you're not learning anything.
If you're referring to how you type in an EOF, then pressing ctrl-z is usual for DOS/Windows.
Eg.
This is a line
ctrl-z
Would cause your program to see "This is a line\n" and then the EOF value
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I'm using Dev-Cpp IDE with Mingw compiler and in my stdio.h I found that EOF is defined as:
but you shouldn't be concerned about it. What is important is to use it effectively, please look at the FAQ.Code:#define EOF (-1)
Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem
I think the end-of-file marker in files opened in text mode is represented by 0x1A (26) character.
Please execute this code:
where Test2.txt is in attachment.Code:int main(void) { FILE *fp; int x, ret_val = 0; fp = fopen ("Test2.txt", "r"); while ((ret_val = fscanf(fp, "%d",&x)) != EOF) { printf("%d ", x); } printf ("\n\n%d", ret_val); return 0; }
Tell me what is your output and which OS you're using!
Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem
It doesn't matter what mode you open it in. EOF canno...wait a second! I already answered this!Originally Posted by Viorel
Quzah.
Hope is the first step on the road to disappointment.
Some day, I swear I'm gonna write a libstdc with EOF as -0xE0F, just to throw all these idiots severely off track.
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
I think EOF = Ctrl+C (on Windows).
No. It doesn't. Not at all.Originally Posted by X.Cyclop
This bad thread was so close to death, why try to revive it?
If you understand what you're doing, you're not learning anything.