In my program, I have a char array (char data[]) from which i have to extract the data and store it in an integer variable(value). To do so, I have used atoi in my program. Problem is that I sometime receive null in the char array(data). If i use atoi on this value, I get the value 0 in integer variable instead of (null)
The real function is quite big and I cannot post the entire code here. From function mentioned below, I hope you guys will get some idea about what I am doing here.
Get_Data(char data[])
{
int value;
value = atoi(p);
}
I recently read that we should use strtol instead of atoi. I tried that too. but I am still getting 0 in variable value.
I want to know which function should i use so that i get (null) in integer variable value?
By null, I mean empty character array here
Please provide solutions specific to the problem. In the above function, if data gets empty char value, how do i make sure that my int variable value also gets empty value and not zero??