Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using an EOF statement with character reversing(about earlier post)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to thank you guys for helping me out earlier about reversing characters in arrays, but I forgot to add that the program has to be able to read in as many characters as the user wants until EOF(ctrl+z, right?), then reverse them all. This is what I have so far(keep in mind that that I just used 30 to test my loops to see if it was reversing the characters). Now, I just need to fit in a while loop to continue to read until the user enters "CTRL+Z.":

#include <stdio.h>

void main()

{

static char phrase[80];
char ch;
int i;

while(ch = getchar(), ch >= 0)

for(i=0; i<80; ++i)
scanf(&quot;%c&quot;, &phrase);

for(i=79; i>=0; --i)
printf(&quot;%c&quot;, phrase);

}


Again, I thank you for the help. My college professor is no help whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top