This is for homework . Must use only getchar and putchar
int main(void) {
int pch; //first
int ch; //second
while(1){
pch=getchar();
ch=getchar();
if(((pch>='A' && pch<='Z')) && ((ch>='A' && ch<='Z'))){
putchar(ch);
putchar(pch);
}
if((pch>='A' && pch<='Z') && ch=='\n') putchar(pch);
if(pch=='\n' || ch=='\n') break;
}
return EXIT_SUCCESS;
}
I need to swap chars using getchar and putchar . For exemple PARIS APIRS
And it works , but i need to hit ENTER two times when i even number of letters 4,6,8... . How do i eliminate this behavior ? Is there some way to kill \n for getchar