nineteenth exercise

This commit is contained in:
celso 2022-11-09 21:17:22 -03:00
parent 16d0011d18
commit f6ed1a2723
1 changed files with 32 additions and 0 deletions

32
1-19.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#define MAXLINE 1000
int ggetline(char line[], int maxline){
int c, i;
for(i=0; i<maxline-1 && (c=getchar()) != EOF && c != '\n'; i++){
line[i]=c;
}
line[i]='\0';
return i;
}
void reverse(char s[]){
int i;
for(i=0; s[i] != '\0'; i++){
;
}
while(i>=0){
putchar(s[i]);
i--;
}
putchar('\n');
}
int main(){
char line[MAXLINE];
int len;
while((len=ggetline(line, MAXLINE))>0){
reverse(line);
}
return 0;
}