First of all - c does not looks on your indentation, it looks on braces to group commands
Code:
#include <stdio.h>
#include <string.h>
#define MAX 79
int main(int argc, char *argv[])
{
char *temp, *first;
int i=10;
char next[i];
char line[MAX];
char line_copy[MAX];
FILE *fp;
//opens files
fp=fopen(argv[1],"r");
//gets and print line
if (fgets(line, MAX, fp)!=NULL)
printf ("Line: ");
puts(line);
printf("Reversed: ");
strcpy(line_copy,line);
//pulling the first substring out
first= strtok(line_copy, " ");
//pulling out substrings after the first
for (i=0;i<=strlen(line);i++){
next[i]=strtok(NULL, " ");
//swapping the words
for (i=strlen(line);i>=0;i--)
temp=0;
*temp=next[i];
next[i]=next[i-1];
next[i-1]= *temp;
printf("%s", next);
}
printf("%s",first);
fclose(fp);
return 0;
}
And another
Code:
temp = 0; //makes temp nul pointer where you cannot store anything
*temp = ...; //tries to store something in the non-existing location and your program crashes
You need
to be able to store char in it