reconversion from int to char

why doesn't the operation at the line 12 work???

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
char c[15];
//Funzione per codificare una stringa
char encode(char *c){
	int i,n;
	char f[((strlen(c))*2)+1];
	char a;
	for(i=0; i<strlen(c); i++){
		n=c[i];
		n=126-(n-33);
		a=n;
		c[i]=a;
		f[i*2]=c[i];
		printf("%d\n",c[i]);
	}
	for(i=0; i<strlen(f); i++){
		
	}
}
What do you mean by "doesn't work"?

Do you compile with C++ or with latest version of C? Only the latter supports (officially) VLA (variable length arrays) that the line 5 requires.
Also how do we know that c is actually a string and not just an array of char?

By the way the current C standard makes the "feature" on line 5 optional. The only standard that mandates this "feature" is C99.

Topic archived. No new replies allowed.