I have array in which i want to store values like this 1203
char* arr= new char[10];
arr[0] = 1;
arr[1] = 2;
arr[2] = 0;
arr[3] = 3;
but after storing 0 i am not able to see any further data bcs it’ll consider that as end of the data. is there any way to manage this??
0means end of string in thechar*.Because
char*is a string in C and it exists to be used as char array not asintegerarray. All function related on string are intended to be used with a string.You can use
int*to storeintegers.You can do the binary operations manually like this :
you can use
uint8_torintinstead ofchar.the
(char*)((int)value)is not good because you cast theinttochar*, but thechar*is the variabletempnot the number to be stored intemp.If pointers is a new thing for you, it will be helpful to do some exercises in pointers : manipulate arrays, lists,…