Hi,
I have no knowledge of C but have been asked to modify a file to carry out a task. What I am trying to do is to use a global variable to replace a particular variable in a config file.
Under the include section I have added the following:
int globalvar;
In the main() section I have:
globalvar = 100;
and in the function block I have:
if (my criteria are met)
{
globalvar++;
char strBuf[16];
int len;
sprintf(strBuf, "%d", gcount);
len = strlen(strBuf);
When I try to compile this, using the Solaris cc compiler, I am getting the following error:
line 129: syntax error before or at: char
line 132: undefined symbol: strBuf
line 132: warning: improper pointer/integer combination: arg #1
undefined symbol: len
I have tried replacing the incrementing of globalvar with:
int localvar = globalvar + 1;
and this compiles fine and outputs the globalvar incremented by 1 for each instance. However I want to be able to increment the globalvar each time the condition is met so the number should increment over and over.
Can anyone please advise on what I am doing wrong.
Thanks,
toddyl
I have no knowledge of C but have been asked to modify a file to carry out a task. What I am trying to do is to use a global variable to replace a particular variable in a config file.
Under the include section I have added the following:
int globalvar;
In the main() section I have:
globalvar = 100;
and in the function block I have:
if (my criteria are met)
{
globalvar++;
char strBuf[16];
int len;
sprintf(strBuf, "%d", gcount);
len = strlen(strBuf);
When I try to compile this, using the Solaris cc compiler, I am getting the following error:
line 129: syntax error before or at: char
line 132: undefined symbol: strBuf
line 132: warning: improper pointer/integer combination: arg #1
undefined symbol: len
I have tried replacing the incrementing of globalvar with:
int localvar = globalvar + 1;
and this compiles fine and outputs the globalvar incremented by 1 for each instance. However I want to be able to increment the globalvar each time the condition is met so the number should increment over and over.
Can anyone please advise on what I am doing wrong.
Thanks,
toddyl