Hello!
I'm doing this homework of reversing an inputted string. However, I was just wondering, if I have two files, one main.c and the other tnirp.c, how do I run main.c so that it incorporates the function in tnirp.c?
Here is the code for tnirp.c
and here is the code for main.c:Code:#include<stdio.h> #include<string.h> void tnirp( char s[] ){ int length = strlen(s); char s2[100]; int i=0; int j=0; for (i=length-1; i>=0;i=i-1){ s2[j]=s[i]; j=j+1; } printf("%s\n",s2); return; }
Code:#include<stdio.h> #include<strings.h> void tnirp( char s[] ); int main(void) { char s[100]; printf("Enter string:\n"); fgets(s, 100, stdin); tnirp(s); return 0; }