array

The program was supposed to copy the user's input. However, the EAPP or the input where the user types numbers, doesn't show on the output. Only bunch of numbers

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  #include <iostream>
using namespace std;

struct student
{
	char name[1];
	char nationality[1];
	float grade, ave, rate;
	
}s[1];

int main ()
{
	cout<<"-------------------------------------------------------------"<<endl
        <<"              Additional Activity for Array: "<<endl
        <<"-------------------------------------------------------------"<<endl;
        
        cout<<endl;
        cout<<endl;
	
	for (int i=0; i<1; ++i)
	{
		
		cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
		cout<<"                  USER INFORMATION  "<<endl
		
		    <<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl
		    <<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl
		    <<endl
		    <<endl;
		 
		cout<<"Enter Name (SURNAME, First Name, Middle Name): ";
		cin>>s[i].name;
		
		cout<<"Enter EAPP Grade: ";
		cin>>s[i].grade;
		
		cout<<"Enter EAPP Average: ";
		cin>>s[i].ave;
			
		cout<<"Enter C++ Self-rating: ";
		cin>>s[i].rate;
		
		 cout<<"Enter Nationality : ";
		cin>>s[i].nationality;
		
		cout<<endl;
		cout<<endl;
		
		
		cout<<"============================================="<<endl;
		    
		cout<<"       DISPLAY THE USER INFORMATION"<<endl;
		
		cout<<"=============================================="<<endl;
		for(int i=0; i<1; i++)
		{
	
		   
		   cout<<"              Name: "<<s[i].name<<endl;
		   cout<<"              Nationality: "<<s[i].nationality<<endl;
		   cout<<"              EAPP Grade: "<<s[i].grade<<endl;
		   cout<<"              EAPP Average: "<<s[i].ave<<endl;
		   cout<<"              C++ Rating: "<<s[i].rate<<endl;
		   
		   
		   cout<<"==========================================="<<endl
		       <<"==========================================="<<endl
		       <<"                                           "<<endl
		       <<"End of Program.";
		       
		       return 0;
		       
	}
}
}
L6, 7 - do you mean to have name and nationality as only 1 char?

L33. This will only accept chars up to a white-space char. Even after you have changed the size of name, input like foo bar will only accept the foo. then grade will try to input bar and fail.

L33. use getline() instead http://www.cplusplus.com/reference/istream/istream/getline/
Topic archived. No new replies allowed.