I have buffer with my data. From a particular character i.e A character I wanted to copy next 40 elements into another buffer and I wanted to discard the rest. Buffer I took as function argument
char *MyBuff(unsigned char *input)
for searching element in that buffer I am using for loop.
for (i = 0; input[i] != NULL; i++) {
if (input[i] == 'MyElement') {
// from that element I wanted to copy data till 40th element
for (i = 1; i <= 41; i++) {
output[i] = input[i];
input++;
}
}
}
return output;
But from above I am not able to receive any data. What I am missing.? Pasting full function here..
unsigned char output[42];
char *MyBuff(unsigned char *input) {
char i;
for (i = 0; input[i] != NULL; i++) {
// search from starting of input array
if (input[i] = 'a') { //if character is found
for (i = 1; i <= 41; i++) {
// copy next 41 character in ouput
ouput[i] = input[i];
input++;
}
}
}
return output; // return the buffer with output
}