- #1
sozener1
- 19
- 0
Im working on some programme
and I've used getchar() putchar() to read sentences in a text file
I open the file usin stdin < filename.txt format
and here is my code
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i;
printf(" ");
while((i=getchar())!='l'){
putchar(i);
}
return 0;
}
and here is the first few sentences in the file
"Project Gutenberg's Alice's Adventures in Wonderland, by Lewis Carroll
This eBook is for the use of anyone anywhere at no cost and with"
the code works fine for most part and prints out every single characters correctly including the space EXCEPT for "P" from Project in the first sentence
it gets printed out in a very weird symbols
can anyone help me figure out what is wrong
and I've used getchar() putchar() to read sentences in a text file
I open the file usin stdin < filename.txt format
and here is my code
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i;
printf(" ");
while((i=getchar())!='l'){
putchar(i);
}
return 0;
}
and here is the first few sentences in the file
"Project Gutenberg's Alice's Adventures in Wonderland, by Lewis Carroll
This eBook is for the use of anyone anywhere at no cost and with"
the code works fine for most part and prints out every single characters correctly including the space EXCEPT for "P" from Project in the first sentence
it gets printed out in a very weird symbols
can anyone help me figure out what is wrong