Sorting? Or Searching

Pages: 1... 34567
Dec 30, 2012 at 11:15pm
if I open the file before call the function visual studio doesn't have a definition for Data Entry.?
Dec 30, 2012 at 11:36pm
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
void DataEntry(Details &member){
	
	
	cout << "First Name: ";
    getline(cin, member.FirstName);
	

    cout << "Last Name: ";
    getline(cin, member.LastName);
	

	cout << "Age(Please Enter an Integer(Number)): ";
    cin >> member.Age;
	

	cout << "Email: ";
	getline(cin, member.Email);


    cout << "Door Number(Please Enter an Integer(Number)): ";
    cin >> member.DoorNumber;
	

    cout << "Road Name: ";
    getline(cin, member.RoadName);
	

    cout << "Post Code(NOTE:Please use Lower Case): ";
	getline(cin, member.PostCode);
	

}

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
void SaveData(Details Data[],int size,Details &member ){
ofstream DataSave("test.txt");
	for(int i;i<size;i++);{
	DataSave <<"\n";
	cout << "First Name: ";
    getline(cout, member.FirstName);
	DataSave << member.FirstName<<"\t";

    cout << "Last Name: ";
    getline(cout, member.LastName);
	DataSave << member.LastName<<"\t";

	cout << "Age(Please Enter an Integer(Number)): ";
	DataSave << member.Age<<"\t";

	cout << "Email: ";
	getline(cout, member.Email);
	DataSave << member.Email<<"\t";

    cout << "Door Number(Please Enter an Integer(Number)): ";
    cout >> member.DoorNumber;
	DataSave << member.Age<<"\t";

    cout << "Road Name: ";
    getline(cout, member.RoadName);
	DataSave << member.RoadName<<"\t";

    cout << "Post Code(NOTE:Please use Lower Case): ";
	getline(cout, member.PostCode);
	DataSave << member.PostCode<<"\t";
	DataSave <<"\n";
	}
	DataSave.close();

}


this is what I have now
Last edited on Dec 30, 2012 at 11:37pm
Dec 30, 2012 at 11:37pm
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(468) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(395) : see declaration of 'std::getline'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

THese are the error messages I get now
Dec 31, 2012 at 12:11am
You should format your error message. Most likely those are compling errors.

Try to correct those errors, please look at line e.g string(line position) string(395). If you need help, copy the error line with code and post them here.
Dec 31, 2012 at 12:14am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(479) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(468) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::ostream'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(448) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(177): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(395) : see declaration of 'std::getline'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on Dec 31, 2012 at 12:14am
Dec 31, 2012 at 12:14am
like that?
Dec 31, 2012 at 1:45am
any ideas?
Dec 31, 2012 at 2:20am
closed account (D80DSL3A)
Try this;
1) Change every 'cout' to 'cin' where it appears in getline().
2) initialize i=0 on line 3.
3) Change every 'member' to 'Data[i]'.
4) Eliminate the 3rd parameter Details &member.
Last edited on Dec 31, 2012 at 2:26am
Dec 31, 2012 at 2:26am
am I glad to see you


it says member is an undeclared identifier.
Dec 31, 2012 at 2:34am
closed account (D80DSL3A)
member doesn't belong in your SaveData(). Did you miss one? It should be gone completely.
Dec 31, 2012 at 2:39am
getline(cin, member.FirstName);

in here???
Dec 31, 2012 at 2:39am
nevermind I ignored point 3
Dec 31, 2012 at 2:40am
getline(cin,Data[i].FirstName); like this?


Dec 31, 2012 at 2:43am
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
void SaveData(Details Data[],int size){
ofstream DataSave("test.txt");
	for(int i=0;i<size;i++);{
	DataSave <<"\n";
	cout << "First Name: ";
    getline(cin, Data[i].FirstName);
	DataSave <<  Data[i].FirstName<<"\t";

    cout << "Last Name: ";
    getline(cin,  Data[i].LastName);
	DataSave << Data[i].LastName<<"\t";

	cout << "Age(Please Enter an Integer(Number)): ";
	DataSave <<  Data[i].Age<<"\t";

	cout << "Email: ";
	getline(cin,  Data[i].Email);
	DataSave <<  Data[i].Email<<"\t";

    cout << "Door Number(Please Enter an Integer(Number)): ";
    cin >>  Data[i].DoorNumber;
	DataSave <<  Data[i].DoorNumber<<"\t";

    cout << "Road Name: ";
    getline(cin,  Data[i].RoadName);
	DataSave <<  Data[i].RoadName<<"\t";

    cout << "Post Code(NOTE:Please use Lower Case): ";
	getline(cin,  Data[i].PostCode);
	DataSave <<  Data[i].PostCode<<"\t";
	DataSave <<"\n";
	}
	DataSave.close();

}



Now I have this give me a heap of errors xD
Dec 31, 2012 at 2:45am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(395) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(192): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(192): error C2228: left of '.Email' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(195): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(195): error C2228: left of '.DoorNumber' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(196): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(196): error C2228: left of '.DoorNumber' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(199): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(199): error C2228: left of '.RoadName' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(199): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(468) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(199): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(395) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(200): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(200): error C2228: left of '.RoadName' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(203): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(203): error C2228: left of '.PostCode' must have class/struct/union
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(203): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(468) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(203): error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\string(395) : see declaration of 'std::getline'
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(204): error C2065: 'i' : undeclared identifier
1>c:\users\faieq\documents\visual studio 2010\projects\attempt 2 challange 1\attempt 2 challange 1\attemp2.cpp(204): error C2228: left of '.PostCode' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


lots of this
Dec 31, 2012 at 2:54am
closed account (D80DSL3A)
OK. Try fixing the first problem and lets see how the error messages change.
i is an undeclared indentifier because the for loop begins and ends on line 3 (due to the extra ; on that line).
Dec 31, 2012 at 3:03am
that's all it was. Suprises me sometimes how it is sometimes the most simplest of things ..

ok so this function has replaced my DataEntry array right?

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
void DataEntry(Details &member){
	ofstream DataSave("test.txt");
	
	cout << "First Name: ";
    cin >> member.FirstName;
	DataSave << member.FirstName<<"\t";

    cout << "Last Name: ";
    cin >> member.LastName;
	DataSave << member.LastName<<"\t";

	cout << "Age(Please Enter an Integer(Number)): ";
	cin >> member.Age;
	DataSave << member.Age<<"\t";

	cout << "Email: ";
	cin >> member.Email;
	DataSave << member.Email<<"\t";

    cout << "Door Number(Please Enter an Integer(Number)): ";
    cin >> member.DoorNumber;
	DataSave << member.DoorNumber<<"\t";

    cout << "Road Name: ";
    cin >> member.RoadName;
	DataSave << member.RoadName<<"\t";

    cout << "Post Code(NOTE:Please use Lower Case): ";
	cin >> member.PostCode;
	DataSave << member.PostCode<<"\t";
	DataSave <<"\n";
	
	

}
Last edited on Dec 31, 2012 at 3:04am
Dec 31, 2012 at 3:05am
1
2
3
4
5
6
 getline(cin, Data[i].FirstName);
	DataSave <<  Data[i].FirstName<<"\t";

    cout << "Last Name: ";
    getline(cin,  Data[i].LastName);
	DataSave << Data[i].LastName<<"\t";



also these are now merging for some reason?
Dec 31, 2012 at 3:09am
so when I go to input it comes out like this

First Name: Last Name:ENTER SOMETHING
agE IS fine because I did cin >> age;
Dec 31, 2012 at 3:30am
closed account (D80DSL3A)
The function has replaced it, but I wouldn't stay with that myself.
The DataEntry() function is where the "magic" of writing a Details object to a file occurs. You could call it from your SaveData() function (which would make your SaveData() function have very little code), but you would have to change a couple of things. You can't open and close the file everytime DataEntry() is called. Passing an ofstream object (to the open output file) should work.
You would open and close the file in SaveData().

Option B is you just leave SaveData() as is. It will do the job fine.

I didn't understand the merging problem. Could you explain it again please?
Last edited on Dec 31, 2012 at 3:30am
Pages: 1... 34567