Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
char *sdup(char* s);
char *supper(char *s)
int main()
{
char s[80], *p;
printf("enter a string> ");
fgets(s, 80, stdin);
fputs(s, stdout);
p = supper(s);
fputs(p, stdout);
free(p);
return EXIT_SUCCESS;
}
char *sdup(char* s)
{
char *p = malloc(strlen(s)+1);
return strcpy(p, s);
}
char *supper(char *s)
{
char *p = strdup(s);
int i;
for(i = 0; p[i]; i++)
p[i] = toupper(p[i]);
return p;
}
after trying to complie:
Code:
$ gcc -o caps caps.c
caps.c: In function ‘supper’:
caps.c:10: error: syntax error before ‘{’ token
caps.c:31: error: syntax error before ‘for’