zadani g++ -v vyhodi
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2 p1.0.2)
Zdrojovy kod programu :
tak chyba nastava pri cikle while
nazov chyby :Segmentation fault
škoda že ten kód nemôžeme posúdiť.
#include <iostream>
#include <string>
using namespace std;
class Osoba{
string meno,
priez,
adresa,
tel_cis,
vek,
mail;
public:
Osoba();
void pridaj();
void vypis();
string vrat(int co);
Osoba *dal,*pred;
};
Osoba::Osoba(){
dal=NULL;
pred=NULL;
}
string Osoba::vrat(int co){
switch(1){
case 1:return meno; break;
case 2:return priez; break;
case 3:return adresa; break;
case 4:return tel_cis; break;
case 5:return vek; break;
case 6:return mail; break;
default: return "";
}
return "";
}
void Osoba::pridaj(){
cout<<"Zadaj meno:";
cin>>meno;
cout<<"Zadaj priezvisko:";
cin>>priez;
cout<<"Zadaj adresu";
cin>>adresa;
cout<<"Zadaj telefone cislo:";
cin>>tel_cis;
cout<<"Zadaj vek";
cin>>vek;
cout<<"Zadaj mail:";
cin>>mail;
}
void Osoba::vypis(){
cout<<"Meno: "<<meno<<"\t"<<"Priezvisko: "<<priez<<endl;
cout<<"Vek: "<< vek<<endl;
cout<<"Adresa: \n\t"<<adresa<<endl;
cout<<"Telefone cislo: "<<tel_cis<<endl;
cout<<"Email: "<<mail<<endl;
}
class Osoby: public Osoba {
class Osoby: public Osoba {
private:
Osoba *zac;
public:
Osoby();
void pridaj();
void vypis();
void utriet();
};
Osoby::Osoby(){
zac=NULL;
}
void Osoby::pridaj(){
Osoba *pridavana;
Osoba *pom;
pridavana = new Osoba;
pridavana->pridaj();
if(zac==NULL){
zac=pom;
}
else{
pom=zac;
#ifdef test
cout<<"pridelil som pom=zac\n";
if(pom->dal==NULL) cout<<"pom->dal ma hodnotu NULL\n"; // Pri tomto mi to pada
else cout<<"pom nemalo hodnotu NULL\n";
#endif
while(pom->dal != NULL){
#ifdef test
static int i;
cout<<"vetva while urobena po:"<<i++<<" krat\n";
#endif
pom=pom->dal;
}
pridavana->pred=pom;
pom->dal=pridavana;
}
}
void Osoby::vypis(){
Osoba *pom;
cout << "zac vypisu\n";
pom=zac;
cout <<"pridelil\n";
cout<<"\n\n";
while(pom!=NULL){
pom->vypis();
pom=pom->dal;
}
}
void Osoby::utriet(){
cout<<"\nNa tejto casti sa este pracuje ;-))\n";
}
int main(){
Osoby pom;
pom.pridaj();
pom.pridaj();
pom.vypis();
return 0;
}
:D ale stale tomu nechapem
neviem potom v com je problem
(gdb) run
Starting program: /home/misolax/prog
Zadaj meno:misolax
Zadaj priezvisko:kusd
Zadaj adresusd
Zadaj telefone cislo:sd
Zadaj veksd
Zadaj mail:sd
Zadaj meno:lool
Zadaj priezvisko:sd
Zadaj adresusd
Zadaj telefone cislo:sd
Zadaj veksd
Zadaj mail:sd
Program received signal SIGSEGV, Segmentation fault.
0x00000000004011e6 in Osoby::pridaj (this=0x7fff3b09f490) at Projekty/C++/db_serve-clijent/osoba.cpp:84
84 while(pom->dal != NULL){
commands breakpoints
a potomrun ./prog
(gdb) run ./prog
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/misolax/prog ./prog
Zadaj meno:misolax
Zadaj priezvisko:ksdf
Zadaj adresusdf
Zadaj telefone cislo:sdf
Zadaj veksdf
Zadaj mail:sdf
Zadaj meno:linuxos.sk
Zadaj priezvisko:ksdf
Zadaj adresusdf
Zadaj telefone cislo:sdf
Zadaj veksdf
Zadaj mail:sdf
Program received signal SIGSEGV, Segmentation fault.
0x00000000004011e6 in Osoby::pridaj (this=0x7fff8305d810) at Projekty/C++/db_serve-clijent/osoba.cpp:84
84 while(pom->dal != NULL){
(gdb) main() breakpoint,
Undefined maintenance command: "() breakpoint,". Try "help maintenance".
(gdb) breakpoint
Undefined command: "breakpoint". Try "help".
(gdb) run ./prog main() breakpoint
Starting program: ./prog main() breakpoint
No executable file specified.
Use the "file" or "exec-file" command.
(gdb)
http://www.root.cz/clanky/gdb-pro-normalni-lidi/
dal som ho naopenpaste.org
dufam ze si spokojny :D