I wanted to make a simple program that writes chracters in a file but i didnt want to press enter .So i found the getchar which doesnt need enter.If i pass (int) getchar to putc ,in the file it shows a P character.The (int) getchar says it is equal to1734747216 so i do (int) getchar-1734747216 and it gives -62259200 and i cant understand why doesnt it give 0 and what is the P symbol since i didnt press any button?So i found that P symbol is the value of (char*)getchar and i wrote this code
#include <stdio.h>
int main()
{
FILE* text;
char* compare=(char*)getchar;
int temp=0;
text=fopen("C:\\cat.txt","w+");
while(1)
{
if ((char*)( temp = (int)getchar )!= compare)
{
putc(temp,text);
}
}
return(0);
}
Also if i change the != with == then the txt has iside it a P symbol as expected but the one with the != still doesnt work as expected
by me
I said "The following code writes characters to the file. (You need to press <ENTER> once before entering EOF - <CTRL>D in UNIX <CTRL>Z in Windows)"
Can you, please tell me in what I am wrong?