Sample to load and save a file
- From: "Benno Mielke" <g00Ze web de>
- To: gtk-app-devel-list gnome org
- Subject: Sample to load and save a file
- Date: Tue, 5 Aug 2003 17:06:50 +0200
In the last days i've tried to to create a menu with GTK+1.2 and C. But then there grows a problem i haven't
been able to solve... when i load a file:
/*--- start code ---*/
FILE* Stream;
gchar File[1024];
FileName = gtk_file_selection_get_filename( GTK_FILE_SELECTION( fs ) );
Stream = fopen( FileName, "r" );
if( Stream == NULL )
{
perror( "GsEditor" );
gtk_main_quit();
exit( -1 );
}
gtk_widget_destroy( GTK_WIDGET( FileDialog ) );
while( 1 )
{
nChar = fread( File, 1, 1024, Stream );
gtk_text_insert( GTK_TEXT( TextField ), NULL, NULL, NULL, File, nChar );
if( nChar < 1024 )
break;
}
/*--- end code ---*/
... and the file is bigger than 1024 bytes there is a BO (BufferOverflow). How to solve this ?
Is there anybody who knows a sample or anybody who can say how to code this function better ?
THX ahead ... so long
Benno M.
______________________________________________________________________________
Wo gibt es den besten Spam-Schutz? Laut ComputerBild 15-03 bei
WEB.DE FreeMail - Deutschlands beste E-Mail - http://s.web.de/?mc=021122
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]