r/C_Homework • • Sep 29 '16

Invalid Initializer when compiled

#include<stdio.h>

void revS(char *S, int a, int b)
{
   int i, j;
   i=a;
   j=b
   char temp;
   while(i<j){
    temp=S[i];
    S[i]=S[j];
    S[j]=temp;
    i++;
    j--;
   }
}

int main(){
    char S[]="abcdefg";
    printf("%s\n",S);
    char A[]=revS(S,3,4);
    printf("%s", A);    
    return 0;
}

those are my code. for some reason when i compiled i got this Invalid Intializer error. can someone please explain what do i do wrong?

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/new_day_yo Oct 02 '16

Thanks for your explanation. Really helpful