Re: My Gscanner Problem...
- From: Iago Rubio <iago iagorubio com>
- To: u821417 alumni nthu edu tw
- Cc: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Re: My Gscanner Problem...
- Date: Wed, 09 Aug 2006 17:29:17 +0200
On Wed, 2006-08-09 at 14:34 +0800, u821417 wrote:
I would like to parse a txt data, and there is "@data" keyword in it.
What i wanna do is take the number after the keyword ,and change it into a hex number.
I cannot get the data after the "@data" keyword so far...
:(
Yes you can, but you're not checking its type.
Furthermore the line printf("\n\n\ndata=0x%x\n",DATA) is obviously wrong
printf("\n\n\ndata=%s\n",DATA).
ttype=g_scanner_get_next_token(scanner);
printf("@data is=0x%x\n",scanner->value.v_int);
sprintf(DATA,"0x%x",scanner->value.v_int);
printf("\n\n\ndata=0x%x\n",DATA);
Try this:
ttype=g_scanner_get_next_token(scanner);
if ( ttype == G_TOKEN_INT ){
printf("@data is=0x%x\n",scanner->value.v_int);
sprintf(DATA,"0x%x",scanner->value.v_int);
printf("\n\n\ndata=%s\n",DATA);
}else{
printf ("data is not int (%s)\n", scanner->value.v_string);
}
Cheers.
--
Iago Rubio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]