Making CV Using Arrays

Hey Guys I Hope You All Are Fine I Just Want A Little Help Here is My Code Below I Am Getting Input From User For CV Now I Want To Print The Output After User Input Complete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int d;
	for(d=1;d<5;d++)
	{
		for(int e=1;e<d;e++)
		{
		char a[50];
	    char b[50];
	    char c[50];
		char f[50];
		char g[50];
		cout<<"********************************"<<endl;
		cout<<"****************CV**************"<<endl;
		cout<<"Enter Your Name:"<<endl;
		cin.getline(a,50);
		cout<<"Enter Your Father Name:"<<endl;
		cin.getline(b,50);
		cout<<"Enter Your CNIC:"<<endl;
		cin.getline(c,50);
		cout<<"Enter Your Gender:"<<endl;
		cin.getline(f,50);
		cout<<"Enter Your House Address:"<<endl;
		cin.getline(g,50);
		}
	}
	system("PAUSE");
	return 0;
}


Now Tell Me Where To Put Cout<<

Waiting For Your Reply
1
2
3
4
5
char a[50];
char b[50];
char c[50];
char f[50];
char g[50];


are local to
1
2
 for(int e=1;e<d;e++)
		{

They are going to loose their value after the loop so put the cout in the loop itself.
But practically doesn't make sense so move your arrays out of the loops.

Also, I am not sure what you are trying to achieve by embedding the for loops
As codewalker said. you have to take the scope of your variables into account. Once you have the input in your arrays. What do you intend to do with them?
Once you leave the inner loop they do not exist. Sure if you just want to parrot back the input this will work with the cout << inside the inner for loop.

for(int e=1;e<d;e++)

Also this will not run the first time through the outer loop. d=1 initially so the first check of e<d will be false.

You also need to consider the inner loop referencing the d variable. When
d == 4 The inner loop will run 3 times before d gets incremented.
Last edited on
as i want to make an cv using array for 5 people so that`s why I take loop the first loop will guide the nested loop to how many time that program run my problem solve I need to put cout<< in the loop any ways thanks for the guidance
Then you will have to implement all the above comments and in addition

1) Will have to define structure with a,b,c,f,g arrays as members
2) declare a vector of this structure, store the inputs in structure and add that to the vector

so the steps

move the arrays out of the loops
implement above 2 steps
get rid of the inner loop altogether
Topic archived. No new replies allowed.