little encoder doesn't work

When i open this program windows says that it stopped working. Why???

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<stdio.h>
#include<string.h>
char *c;
//Funzione per codificare una stringa
char encode(char *c){
	int i,n;
	char f[strlen(c)];
	for(i=0; i<strlen(c); i++){
		n=c[i];
		f[i]=n++;
		printf("%d",f[i]);
	}
}

//Corpo del programma
int main(){
	printf("Inserisici una stringa da codificare: ");
	gets(c);
	encode(c);
	return 0;
}
oh sorry i have just correct one thing so THIS one is the real encoder

#include<stdio.h>
#include<string.h>
char *c;
//Funzione per codificare una stringa
char encode(char *c){
int i,n;
for(i=0; i<strlen(c); i++){
n=c[i];
c[i]=n++;
printf("%d",c[i]);
}
}

//Corpo del programma
int main(){
printf("Inserisici una stringa da codificare: ");
gets(c);
encode(c);
return 0;
}
Topic archived. No new replies allowed.