I had to make code where certain letters of upper case has to change to numbers.
A - 4
B - 8
E - 3
I - 1
O - 0
S - 5
So, for example it would be like this :
This stuff really works ----> TH15 5TUFF R34LLY W0RK5
And that's the code:
insert
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
const char* TABLE[] = { "ABEIOS", "483105" };
int main(void) {
char *a;
char str[1000], *ptr;
printf("%s\n", "enter the string:");
if(scanf("%s", &*a) != 1) {
printf("input error\n");
exit(EXIT_FAILURE);
}
for ( ptr = str; ptr; ++ptr ) {
*ptr = toupper(*ptr);
if (( a = strchr(TABLE[0], *ptr) ) != NULL );
*ptr = (TABLE[1][a - TABLE[0]]);
}
printf("%s\n", str);
}
And then i trying to compile this , i get "Segmentation fault".
How to fix it ?
thx)