I want to convert from one string to another and return it as a pointer *out_s? or as a string "res" will be ok as well. But my code doesn't work...
For example, copying res[n] = (char *)&out; doesn't work.
What is wrong with my code?(I am new to C, so please bear with me)
int readAndConvert(char *in_s, char *out_s, int len){
int n=0;
int *out, *in;
char *res = malloc(sizeof(char)*len);
for(n=0; n<len; n++){
in = (int*)(in_s[n]);
out = (int*)(out_s[n]);
convertChar(&in, &out,1);
res[n] = (char *)&out;
}
res;
return 0;
}
int convertChar(int *in_char, int *out_char, int enc){
uchar *table;
table = ki;
if(*in_char & 0x80){
*out_char = table[*in_char & 0x7F];
}
else{
*out_char = *in_char;
}
return 0;
}
For example, copying res[n] = (char *)&out; doesn't work.
What is wrong with my code?(I am new to C, so please bear with me)
int readAndConvert(char *in_s, char *out_s, int len){
int n=0;
int *out, *in;
char *res = malloc(sizeof(char)*len);
for(n=0; n<len; n++){
in = (int*)(in_s[n]);
out = (int*)(out_s[n]);
convertChar(&in, &out,1);
res[n] = (char *)&out;
}
res;
return 0;
}
int convertChar(int *in_char, int *out_char, int enc){
uchar *table;
table = ki;
if(*in_char & 0x80){
*out_char = table[*in_char & 0x7F];
}
else{
*out_char = *in_char;
}
return 0;
}