Link to home
Start Free TrialLog in
Avatar of demilune
demilune

asked on

Help with variables...

I'm having issues with variables...

I am trying to load some configuration information from a text file and use it elsewhere in my application.

Here are snipets from the code:

char * CIP = "000.000.000.000";
char* IpAddress = CIP;

errno_t err;

if ((err = fopen_s(&instream, "config.txt", "r")) != 0)
{
      Memo1->AppendText("Configuration file failed to open.\r\n");
}
else
{
      Memo1->AppendText("Configuration file successfully opened.\r\n");
                        
      fscanf(instream, "%s\n", CIP);
}

I am getting an "attempted to read or write to protected memory" error when compiling. I know this has to do with pointers and such, but I've never been good with them and I'm stumpted on this one.

I am not able to change the CIP decleration or usage as the other 2000 lines of code work with it as it is. What I need is the read the first line of the text file and then assign that information to the CIP variable.

Any help you be appreciated as this problem is urgent...
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>I am not able to change the CIP decleration or usage as the other 2000 lines of code work with it as it is.
This change should not affect your existing code. ... give it a shot
Avatar of demilune
demilune

ASKER

THANKS THANKS THANKS...

I knew I was missing something simple like that. I had not realized literals were stored read only.

Thanks again!
Glad to help :)