I have to make a C program read ordinary text (a sequence of lines) from the program's standard input, and print it with each line reversed from left to right. It has to be no longer than 80 symbols and it should read until it gets an EOF. Im stumped now...here is what i have so far...
#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 80
int getline(char *, int);
void main() {
char a[MAXLEN];
int i;
int temp;
int n;
getline(a, MAXLEN);
for (i=0; i<n/2; i++) {
temp = a;
a = a[n-i-1];
a[n-i-1] = temp;
printf("%s", a);
system("Pause");
}
/* getline: read a line into s, return length */
int getline(char *s, int lim)
{
int c, i;
for (i = 0; i < lim-1 &&(c=getchar())!= EOF && c != '\n'; ++i)
s = c;
if (c == '\n') {
s = c;
++i;
}
s = '\0';
return i;
}