Let's say I have:-
char Data[1000];
After doing some data extraction and manipulation, passing it around into helper functions (as char * Data
), I am doing the following to remove a leading ','
from the data:-
if (Data[0] == ',') Data++;
And this works like a charm.
However as I was building my code up, I started using struct
, instead of singular variables.
So now I have this:-
struct BigData
{
char Data[1000];
}
I still manipulate it and pass it along and everything works fine until I try to remove the leading ','. My above methodology doesn't work as follows:-
if (_bigData.Data[0] == ',') _bigData.Data++;
for obvious reasons. So I decided to create a temp char
array as follows:-
char temp[1000];
strcpy(temp, _bigData.Data);
if(temp[0] == ',') temp++;
Can anyone explain to me why this doesn't work?
I am just now beginning to code in C (coming from C# where such string manipulations are a very surface level procedure).