#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void str_prn(char **);
int main(void)
{
char temp[80];
char **str;
int max;
int i;
printf("Number of Strings : ");
scanf("%d", &max);
str = (char **)malloc((max+1)*sizeof(char*));
i=0;
while(1)
{
printf("Input the string : ");
scanf("%s",temp);
str[i] = (char*)malloc(strlen(temp)+1);
strcpy(str[i],temp);
i++;
if(i ==max)
{
printf("Complete!!\n\n");
break;
}
}
str_prn(str);
i=0;
while(str[i]!=0)
{
free(str[i]);
++i;
}
free(str);
system("PAUSE");
return 0;
}
void str_prn(char **sp)
{
int i, len=0;
char *reversedSp;
len = strlen(*sp);
while(*sp !=0)len++;
{
for(i=0;i<len;i++)
{
reversedSp = *sp
}
}
return;
}
I want to get the result of input strings reversed. I mean if I get "abcdeqwerty" the result should be result should be "edcbaytrewq"
First I used strrev func but my professor said not to use strrev. So I tried to deal with the matter by using for loop.
In the function str_prn, How can I revise it to work?