hello fellow programmers.
I am having an anoying problem with a Contact book i am making. As the title of this thread suggests i am getting that error but only when i call for a specific function in the program called void search(). All the other functions in the class Adressbok excecute. This all worked fine until today when i was working on it and made some changes this message popped up. Tried to change back to make it work but it just doesnt want to.
I am a bit of a beginner att c++ so dont be to harsh about my code and this is not all finished yet if some parts look strange. Also when I run the debugger a window pops up called Disassebly with the text
00404514 push %ebp
00404515 mov %esp,%ebp
00404517 push %ebx
00404518 sub $0x14,%esp
0040451B mov 0x8(%ebp),%ebx
0040451E lea -0x60(%ebx),%eax
00404521 movl $0x1,-0x60(%ebx)
00404528 mov 0xc(%ebp),%edx
0040452B mov %edx,0x10(%eax)
0040452E mov 0x10(%ebp),%edx
00404531 mov %edx,0x14(%eax)
00404534 mov 0x47b050,%edx
0040453A mov (%edx),%edx
0040453C mov %edx,0x18(%eax)
0040453F mov 0x47b04c,%edx
00404545 mov (%edx),%edx
00404547 mov %edx,0x1c(%eax)
0040454A movl $0x432b2b00,0x40(%eax)
00404551 movl $0x474e5543,0x44(%eax)
00404558 movl $0x404578,0x48(%eax)
0040455F sub $0x20,%ebx
00404562 mov %ebx,(%esp)
00404565 call 0x41402c <_Unwind_SjLj_RaiseException>
0040456A mov %ebx,(%esp)
0040456D call 0x404d30 <__cxa_begin_catch>
00404572 call 0x4041ec <std::terminate()>
00404577 nop
This doesnt mean anything to me but i hope this can help you help me solve the problem.
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int x;
class Adressbok
{
private:
string Namn;
string Ort;
string telefon_number;
string e_mail;
public:
void skriv_in_data()
{
cin.ignore();
cout << "Name: ";
getline(cin,Namn);
cout << "Location: ";
getline(cin,Ort);
cout << "E-mail: ";
getline(cin,e_mail);
cout << "Phonenumber: ";
getline(cin,telefon_number);
}
void skriv_till_fil()
{
ofstream fil("Adressbok.txt", ios_base::in | ios_base::app);
if(fil.is_open())
{
fil << Namn << "\n";
fil << Ort << "\n";
fil << telefon_number << "\n";
fil << e_mail << "\n\n";
fil.close();
}
}
void skriv_context_av_adressbok()
{
ifstream fil("Adressbok.txt", ios_base::out);
if(fil.is_open())
{
while(!fil.eof())
{
string output;
getline(fil,output);
cout << output << endl;
}
fil.close();
}
}
void search()
{
int x=0;
cin.ignore();
string inmatning;
cout << "Type in your search: ";
getline(cin,inmatning);
ofstream fil("Adressbok.txt", ios_base::out);
if(fil.is_open())
{
while(getline(readfile, line))
{
string tomrad;
getline(fil,tomrad);
getline(fil,Namn);
//int pos = Namn.find (' ');
//string efternamn = Namn.substr(pos, 10);
getline(fil,Ort);
getline(fil,telefon_number);
getline(fil,e_mail);
if(Namn == sokning || Ort == sokning || telefon_number == sokning || e_mail == sokning)
{
cout << Namn << endl;
cout << Ort << endl;
cout << telefon_number << endl;
cout << e_mail << endl;
cout << endl;
x++;
}
}
if(x==0)
cout << "Could not find your search" << endl;
fil.close();
}
}
};
int main()
{
do
{
system("CLS");
cout << setw(50) << "**********************" << endl;
cout << setw(50) << "* MIRZAS CONTACTBOOK *" << endl;
cout << setw(50) << "**********************" << endl << endl;
cout << setw(52) << "What would you like to do?" << endl << endl;
cout << setw(45) << "1. Add a new person" << endl;
cout << setw(35) << "2. Search" << endl;
cout << setw(35) << "3. Delete" << endl;
cout << setw(59) << "4. Look at contest of addressbook" << endl << endl;
cout << setw(34) << "Choice: ";
cin >> x;
if(x == 1)
{
Adressbok add_new_person;
add_new_person.skriv_in_data();
add_new_person.skriv_till_fil();
cin.get();
}
else if(x == 2)
{
Adressbok search_funktion;
search_funktion.search();
cin.get();
}
/*else if(x == 3)
{
}*/
else if (x == 4)
{
Adressbok las_fran_fil;
las_fran_fil.skriv_context_av_adressbok();
cin.get();
}
else
{
cout << "Det går inte" << endl;
}
}while(x > 0);
return 0;
}