rather i've used QString with a little bit modification

Code :
Qt Code:
  1. int size;
  2. int i,j,k;
  3. QString send="";
  4. QFile file("/sfiles/mxdrv.tgz");
  5. if(!file.open( IO_ReadOnly ))
  6. {
  7. QMessageBox::information(0,"Error","Error opening file");
  8. }
  9. else
  10. {
  11. cout<<"File opened successfully"<<endl;
  12. }
  13. cout<<"file opened...."<<endl;
  14. unsigned char fname[]="mxdrv.tgz";
  15.  
  16. struct termios t;
  17. char *device = "/dev/ttyS0";
  18.  
  19. int sPort, rbyte, status, sPortdest,length;
  20. long count=0;
  21.  
  22. unsigned char send1[32];
  23.  
  24.  
  25. t.c_cc[VMIN] = 1;
  26. t.c_cc[VTIME]=0;
  27. t.c_cc[VEOF]='\n';
  28.  
  29. t.c_iflag |= (ISIG);
  30. t.c_iflag &= ~BRKINT;
  31. t.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
  32.  
  33. sPort = open(device,O_RDWR|O_NOCTTY|O_NDELAY);
  34.  
  35. if(sPort != -1)
  36. {
  37. cout<<"open successfully\n";
  38.  
  39. status = ioctl(sPort,TCSETS,&t);
  40. cout<<"Entering status"<<status<<endl;
  41. if(status==0)
  42. {
  43.  
  44. //for(count=0;count<20;count++)
  45. cout<<"sending name"<<endl;
  46. rbyte=write(sPort,fname,strlen((char *)fname));
  47. //usleep(3000);
  48. cout<<"name sent"<<endl;
  49. cout<<"now sending file"<<endl;
  50. while(!file.atEnd())
  51.  
  52. {
  53. //cout<<"Enter :";
  54. //cin>>send1;
  55. //strcat((char *)send1,"{MSS TYPE-D DAMA}");
  56. // write(sPort,"{012345678}",11);
  57. cout<<"getting byte from file"<<endl;
  58. i=file.getch();
  59. send.sprintf("%d",i);
  60. cout<<send<<endl;
  61. rbyte=write(sPort,send,strlen(send));
  62. cout<<rbyte<<"sent"<<endl;
  63. //cout<<"w b:"<<rbyte<<"\t Time:"<<count<<"\t string:"<<send1<<"\n";
  64. //usleep(1000);
  65.  
  66. }
  67.  
  68. }
  69. close(sPort);
  70.  
  71. }
  72. else
  73. {
  74. cout<<"Device could not be opened";
  75. }
  76. file.close();
To copy to clipboard, switch view to plain text mode 



when i run the program from the terminal, the bytes get transfered which i can see in the hyperterminal of some other pc.
but then after some time the following comes on the terminal and the program exits abruptly:

*** glibc detected *** ./filetransfer: munmap_chunk(): invalid pointer: 0xbffe8e70 ***
======= Backtrace: =========
/lib/libc.so.6(cfree+0x1bb)[0xe5d67b]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6874871]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QWidget5closeEb+0x1f6)[0x5198e6]
./filetransfer[0x804fdcb]
./filetransfer[0x804fa3b]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QObject15activate_signalEP15QConnectio nListP8QUObject+0x16a)[0x4dbe2a]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QObject15activate_signalEi+0xbd)[0x4dc95d]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QButton7clickedEv+0x2c)[0x86f8ac]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QButton17mouseReleaseEventEP11QMouseEv ent+0xbd)[0x57fa3d]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN7QWidget5eventEP6QEvent+0x3c5)[0x5192d5]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication14internalNotifyEP7QObjec tP6QEvent+0x9b)[0x4730fb]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication6notifyEP7QObjectP6QEvent +0x287)[0x474757]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN9QETWidget19translateMouseEventEPK7_XEv ent+0x576)[0x40af26]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication15x11ProcessEventEP7_XEve nt+0x5e6)[0x409a26]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop13processEventsEj+0x4eb)[0x41b6ab]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop9enterLoopEv+0x42)[0x48c672]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN10QEventLoop4execEv+0x26)[0x48c536]
/usr/lib/qt-3.3/lib/libqt-mt.so.3(_ZN12QApplication4execEv+0x1f)[0x472c0f]
./filetransfer(_ZN7QWidget6createEmbb+0xe2f)[0x804ef2f]
/lib/lAborted


any suggestions ??