I have already looked at this similar question but i am still wondering if there is another way to stop 1) the terminal echoing with portabilty as this is an assignment and I have already had one java program crash and burn on my teachers computer 2) in my program i search for a
char then if it isn t the first char use getchar
then putchar
till the next
char which works fine when using redirected stdin
but when I try using the program without redirection the enter key is always echoed, is this to do with the terminal echoing or do i need to check for a diffrent char apart from
? I have also tried including /r
and done lots of googling but it seems the answer to the echo is can t be done with portabilty?
#include <stdio.h>
#include <string.h>
int first_line(char);
int main(){
char c;
while((c = getchar())!=EOF){
first_line(c);
}
return 0;
}
int first_line(char c){
if (c !=
||c !=
){
putchar(c);
do{
c = getchar();
putchar(c);}
while( c !=
);
}
return 0;
}
感谢Lachlan