Hi,
Any ideas on how to read characters from a .txt and then display them on the screne?
Thanks
Hi,
Any ideas on how to read characters from a .txt and then display them on the screne?
Thanks
Try to do some research before you ask:
http://www.cprogramming.com/tutorial/cfileio.html
first of all i did my recearh BEFORE i asked.
This is my problem
The problem is that it keeps on printing the first chacter over and over again on the screne.Code:do { infile1=fopen("encrypted.txt", "r"); fscanf(infile1, "%s", &output); //printf("lol"); printf("%c", output); } while(output != EOF); // check to make sure user has input
Can anyone see the problem with the code?
BTW: Its my first semester taking C, hence my name.
Well you keep opening the file each time around the loop.
Code:int ch; infile1=fopen("encrypted.txt", "r"); while ( ( ch = fgetc(infile1) ) != EOF ) { putchar( ch ); }
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.
Thanks for your help... since i am still studying C, i was trying to figure out how to do that for a few hours. You saved me a lot of time.
Now I have another problem.
I have to read charcter from a .txt file.
Then i must have some sort of loop that would check for certain characters and replace them with ones that have been predefined by the user using a pointer. (no writing to a file involved yet). Single chatactets only, ie it will not search for a KJ rather for K, then subsitute. Then J, then subsitute.
I figured out how to allow the user to specify the value of the pointers.
Now i have to write to modified characters to another text file.
One more thing, how many people here are computer engineer majors, and how many are computer science?