NEWBIE QUESTION PROBABLY EASY 
Author Message
 NEWBIE QUESTION PROBABLY EASY

I'm sure this has something to do with pointers and addressing etc, but
being new to C I'm still getting used to it...

The variable i has been initialised to 0 at the beginning of main(), and
I've narrowed it down to the point that it just changes unexpectedly -

printf("i=%d\n",i);        //gives i=0
newString[i]=argv[3][i];
printf("i=%d\n",i);        //gives i=112

Any ideas on what's happening are appreciated,
Ian



Tue, 21 Aug 2001 03:00:00 GMT  
 NEWBIE QUESTION PROBABLY EASY
), and
Quote:
> I've narrowed it down to the point that it just changes unexpectedly -

> printf("i=%d\n",i);        //gives i=0
> newString[i]=argv[3][i];
> printf("i=%d\n",i);        //gives i=112

I bet argv[3]p] happens to be a 'p', eh?

Without seing the rest of your program, I suspect
ath newString doesn't isn't initialized appropriately
and when you store into newString[i] you are overwriting
the i variabel.



Tue, 21 Aug 2001 03:00:00 GMT  
 NEWBIE QUESTION PROBABLY EASY


[snip]

Quote:
> printf("i=%d\n",i);        //gives i=0
> newString[i]=argv[3][i];
> printf("i=%d\n",i);        //gives i=112

What sort of variable is newString?  Is it a char *?
If so, have you made it point at memory using new?

--
Dan Evens
(Standard disclaimers etc. No spam please.)



Tue, 21 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. This is a biztalk question but probably an easy question for you C# guru's

2. probably an easy array, rand() question

3. Probably an easy or dumb question

4. Probably a easy question...

5. newbie question (and probably a dumb one)

6. Stupid Newbie Question: SecurityException Occuring (probably a FAQ)

7. Total Newbie to C - Probably silly type questions

8. Newbie Question - Probably Dumb as well

9. [NEWBIE] Probably a silly question

10. class function linkage - probably a newbie question

11. Newbie : probably a very stupid question????

12. Probably an easy one - MessageBox woes

 

 
Powered by phpBB® Forum Software