![]() |
I'm new at programming and i need help
Hi
I'm new at programming and I kind of need help. I trying to create a programming that accept names and in those names you can enter data in them. Well I started creating it but ran in to a few problems. Here's the code: :
#include "stdafx.h"Thank You for your replies!!!:) |
Re: I'm new at programming and i need help
:
for (int iii=0; iii<g_nEmploy; iii++)Is equivilent to: :
for (int iii=0; iii<g_nEmploy; iii++) {But neither of the above are equivilent to: :
for (int iii=0; iii<g_nEmploy; iii++) {The way you indent the lines is irrelevant. Only the braces matter. If braces are excluded where a new block is initiated, only the first line/block is included in the new block. The latter format is the one you want, because both the output and input statements belong to the loop. Otherwise, with the first example, only the output statement belongs to the loop block, thus the input statement does not execute after each output. Hope that helps. Edit: Didn't see your second question. If you want to change the array element each time a name is entered, realize what the index is, and then look at the value of iii for each iteration. I'll let you figure this one out, see if you can make any connections.Post Edit: Ah, no worries. titanium beat me to it. My suggestion for you to try it yourself was more laziness on my part than anything. ;) |
Re: I'm new at programming and i need help
You probably want to update the array index you are writing to as well:
:
for (int iii=0; iii<g_nEmploy; iii++) { |
Re: I'm new at programming and i need help
It's been a while since I learned C++, but it seems you could have something like:
:
Am I wrong? |
Re: I'm new at programming and i need help
Quote:
|
Re: I'm new at programming and i need help
Hi,
Thank you for your replies!!:) Though when I edited the code: :
#include "stdafx.h"Once again Thank You for your replies!!!!:):):) |
Re: I'm new at programming and i need help
Edit:I was also wondering if its possible to put a struct in each element of an array. Thank You!!!:)
|
Re: I'm new at programming and i need help
I'd be happy to be corrected, but I'd say that this is "correct" C++ for your previous problem:
:
I can sympathize with any pain that code may cause. ;) As you your second question: sure. :
|
Re: I'm new at programming and i need help
Quote:
|
Re: I'm new at programming and i need help
This line looks suspect:
string g_pnArray1 = new char[g_nEmploy]; |
| All times are GMT -5. The time now is 3:39 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC