hi guys,
i have declared a char pointer. i am using this in itoa() function to convert integer data into hex data e.g
char * hexData= NULL;
itoa(1484820,hexData,16);
this results in equalent of 1484820 in hex decimal and store it in hexData.
now when I want to some process in hexData(char pointer). when I pass it to my function for further process, the value of hexData(char pointer is changed now contains garbage) see the code below
main()
{
char * hexData=NULL;
itoa(148420,hexData,16);
printf("%s",hexData);---------------------//output is 243C4
writeinFile(hexData,fptr);
}
writeinFile(char* str, FILE *fptr)
{
printf("%s",hexData);---------------------//output is 2434C but some time a garbage value
char *hex = new char[30];
printf("%s",hexData);---------------------//output is always garbage value after any new
//char *pointer declaration.
----
----
----
}
}
I am confused whats problem going on here.
can any tell me its solution?
Asif