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("%c", &phrase);
for(i=79; i>=0; --i)
printf("%c", phrase);
}
Again, I thank you for the help. My college professor is no help whatsoever.
#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("%c", &phrase);
for(i=79; i>=0; --i)
printf("%c", phrase);
}
Again, I thank you for the help. My college professor is no help whatsoever.