[Qt-interest] Segmentation fault while converting from QString to char*
Alexandre Beraud
aberaud at infflux.com
Mon Apr 19 10:07:10 CEST 2010
Hi,
Where is the memory allocation for 'file_name' ? If you allocate before
getting the pointer to ba.data() how do you know the size you need to
allocate ?
Regards,
Alex
prashant bhutani a écrit :
> Hi everyone,
>
> I am making a program which fetch a file from directory using
> *getOpenFileName* and it returns the path as a *QString*.
> Now I have to convert the path in *char** which i am doing using
> *QByteArray ba = qt_file_name.toLatin1(); *//qt_file_name
> is path of file in Qstring
> * const char* temp = ba.data(); *
> * strcpy(file_name,temp); *//
> file_name is in char*
>
> Now the code is causing segmentation fault in my program as it runs
> fine when these statements are made comments.
> Can anyone please tell the reason for segmentation fault and how to
> remove it?
>
> I have also used *toLatin1* ,* toAscii* to convert QSrting to char*
> but all cause same segmentation fault.
>
> Regards,
> Prashant
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Alexandre BERAUD
Ingénieur Développement
Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site : www.infflux.com
More information about the Qt-interest-old
mailing list