I am trying to implement a simple c++ program which takes an input string with punctuation characters and return an output string removing those punctuations. The program is
#include<iostream> #include<cctype> using namespace std; int main() { int index=0; string sequence1,sequence2; cout<<"enter the sequence"<<endl; getline(cin,sequence1); for(index=0;index<20;++index) if(!ispunct(sequence1[index])) sequence2[index]=sequence1[index]; cout<<sequence2<<endl; return 0; } It gives me an error saying ld returned 1 exit status.The total error is
progprac: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here progprac: In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here progprac:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here progprac: In function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here progprac: In function `__data_start': (.data+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here progprac: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here /tmp/ccpOfw2A.o: In function `main': progprac.cc:(.text+0x0): multiple definition of `main' progprac:(.text+0xe4): first defined here /usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__' progprac:(.dtors+0x8): first defined here /usr/bin/ld: error in progprac(.eh_frame); no .eh_frame_hdr table will be created. collect2: ld returned 1 exit status I checked online that it is a linker error where you declare a function and not define it. But I haven't made such an error. What is the error?
g++ -o progprac progprac.cc? or alternativelyg++ progprac.ccto create an executablea.out