Click here to Skip to main content
15,913,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reports in VC++6.0 Pin
Game Tester24-Nov-03 14:04
Game Tester24-Nov-03 14:04 
Generalreceive serial xml data Pin
Anonymous24-Nov-03 8:45
Anonymous24-Nov-03 8:45 
GeneralRe: receive serial xml data Pin
Andrey Del Pozo24-Nov-03 9:39
Andrey Del Pozo24-Nov-03 9:39 
GeneralDll data space Pin
Anonymous24-Nov-03 8:35
Anonymous24-Nov-03 8:35 
GeneralReading raw data Pin
Anonymous24-Nov-03 7:48
Anonymous24-Nov-03 7:48 
GeneralRe: Reading raw data Pin
John M. Drescher24-Nov-03 8:03
John M. Drescher24-Nov-03 8:03 
GeneralRe: Reading raw data Pin
john john mackey24-Nov-03 11:12
john john mackey24-Nov-03 11:12 
GeneralA simple C question Pin
b_girl24-Nov-03 7:35
b_girl24-Nov-03 7:35 
A friend of mine is just learning how to code in C and I've been helping her a little bit along the way. There seems to be a problem with a chunk of her code, and I can't figure out how to fix it, it's been quite a while since I've looked at C so I'm a little 'fuzzy' on it.

The following bit of code is taken right from her source code.

int *suit[4];
for(int p = 0; p <= 3; p++)
{
	suit[p] = &p;
}

...

then inside a loop which will execute the following loop x = 0 to x < 4 times:

printf(" %d", *suit[x]);

The program exits fine, with no errors, but the only problem is, when it prints out at the end, each entry in the suit array is set at being 4 (so the 4 will print out 4 times), when what she want to print out is 0 1 2 3, if she changes the loop to:
for(int p = 0; p <= 4; p++)
{
...
}
the print statement shows that a 5 prints out in each case. I'm sure the problem comes from this suit[p] = &p; but I don't know how to fix it.

Can anyone help us out? Thanks...
GeneralRe: A simple C question Pin
markkuk24-Nov-03 7:52
markkuk24-Nov-03 7:52 
GeneralRe: A simple C question Pin
b_girl24-Nov-03 8:11
b_girl24-Nov-03 8:11 
GeneralRe: A simple C question Pin
John M. Drescher24-Nov-03 7:59
John M. Drescher24-Nov-03 7:59 
GeneralRe: A simple C question Pin
noahsarf24-Nov-03 8:11
noahsarf24-Nov-03 8:11 
GeneralRe: A simple C question Pin
b_girl24-Nov-03 8:22
b_girl24-Nov-03 8:22 
GeneralRe: A simple C question Pin
Rick York24-Nov-03 8:25
mveRick York24-Nov-03 8:25 
GeneralRe: A simple C question Pin
Jesse Evans24-Nov-03 8:23
Jesse Evans24-Nov-03 8:23 
GeneralRe: A simple C question Pin
b_girl24-Nov-03 8:27
b_girl24-Nov-03 8:27 
GeneralRe: A simple C question Pin
John R. Shaw24-Nov-03 17:37
John R. Shaw24-Nov-03 17:37 
GeneralTrig and Calculus Functions in C++ Pin
Trurl_24-Nov-03 7:04
Trurl_24-Nov-03 7:04 
GeneralRe: Trig and Calculus Functions in C++ Pin
John M. Drescher24-Nov-03 7:08
John M. Drescher24-Nov-03 7:08 
GeneralRe: Trig and Calculus Functions in C++ Pin
John R. Shaw24-Nov-03 17:45
John R. Shaw24-Nov-03 17:45 
GeneralRe: Trig and Calculus Functions in C++ Pin
Trurl_25-Nov-03 6:42
Trurl_25-Nov-03 6:42 
GeneralRe: Trig and Calculus Functions in C++ Pin
John R. Shaw25-Nov-03 8:37
John R. Shaw25-Nov-03 8:37 
Questionhow to open a listening port using MFC Pin
Dhakad24-Nov-03 6:51
Dhakad24-Nov-03 6:51 
AnswerRe: how to open a listening port using MFC Pin
Ernesto D.24-Nov-03 9:32
Ernesto D.24-Nov-03 9:32 
AnswerRe: how to open a listening port using MFC Pin
BaldwinMartin24-Nov-03 14:52
BaldwinMartin24-Nov-03 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.