473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

sscanf error for unsign int type.

Hi all,

I encountered a problem for sscanf from a string for unsigned int
type. The warning message is

main.c: In function `main':
main.c:171: warning: unsigned int format, different type arg (arg 3)

================================================== =======
if (begin_scn) {
u_short scn_major;
u_int scn_minor;

if (sscanf(begin_scn, "%4x%*1[.:,]%8x", &scn_major,
&scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return 1;
}
}
================================================== =======

Would anybody tell me how to solve this problem?

Thanks in advance!
Dec 4 '07 #1
4 5656
loudking wrote:
Hi all,

I encountered a problem for sscanf from a string for unsigned int
type. The warning message is

main.c: In function `main':
main.c:171: warning: unsigned int format, different type arg (arg 3)

================================================== =======
if (begin_scn) {
u_short scn_major;
u_int scn_minor;

if (sscanf(begin_scn, "%4x%*1[.:,]%8x", &scn_major,
&scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return 1;
}
}
================================================== =======

Would anybody tell me how to solve this problem?

Thanks in advance!
Use the 'u' format specifier for unsigned int and 'hu' for unsigned
short.

Dec 4 '07 #2
"loudking" <lo******@gmail.comschrieb im Newsbeitrag
news:f9**********************************@l1g2000h sa.googlegroups.com...
Hi all,

I encountered a problem for sscanf from a string for unsigned int
type. The warning message is

main.c: In function `main':
main.c:171: warning: unsigned int format, different type arg (arg 3)

================================================== =======
if (begin_scn) {
u_short scn_major;
u_int scn_minor;

if (sscanf(begin_scn, "%4x%*1[.:,]%8x", &scn_major,
&scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return 1;
}
}
================================================== =======

Would anybody tell me how to solve this problem?

Thanks in advance!
Apparently ip complains about scn_major not being an insigned int, while
scanf'c %X expects it to be just that. Try %hx for unsigned short.

Bye, Jojo
Dec 4 '07 #3
"Joachim Schmitz" <no*********@schmitz-digital.deschrieb im Newsbeitrag
news:fj**********@online.de...
"loudking" <lo******@gmail.comschrieb im Newsbeitrag
news:f9**********************************@l1g2000h sa.googlegroups.com...
>Hi all,

I encountered a problem for sscanf from a string for unsigned int
type. The warning message is

main.c: In function `main':
main.c:171: warning: unsigned int format, different type arg (arg 3)

================================================= ========
if (begin_scn) {
u_short scn_major;
u_int scn_minor;

if (sscanf(begin_scn, "%4x%*1[.:,]%8x", &scn_major,
&scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return 1;
}
}
================================================= ========

Would anybody tell me how to solve this problem?

Thanks in advance!
Apparently ip complains about scn_major not being an insigned int, while
scanf'c %X expects it to be just that. Try %hx for unsigned short.
Guess I'd better spellcheck _before_ sending...
"Apparently it complains about scn_major not being an unsigned int, while
scanf's %x expects it to be just that."

Bye, Jojo
Dec 4 '07 #4
loudking wrote:
main.c: In function `main':
main.c:171: warning: unsigned int format, different type arg (arg 3)
if (begin_scn) {
u_short scn_major;
u_int scn_minor;

if (sscanf(begin_scn, "%4x%*1[.:,]%8x", &scn_major,
&scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return 1;
}
}
Would anybody tell me how to solve this problem?
Note the format specifier below:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
char begin_scn[] = "00ab.721a00ac";
unsigned short scn_major;
unsigned int scn_minor;

if (sscanf(begin_scn, "%4hx%*1[.:,]%8x", &scn_major, &scn_minor)
!= 2) {
fprintf(stderr, "Wrong SCN format: %s\n", begin_scn);
return EXIT_FAILURE;
}
printf("begin_scn is \"%s\"\n"
"scn_major = %#x\n"
"scn_minor = %#x\n", begin_scn, scn_major, scn_minor);
return 0;
}

[output]
begin_scn is "00ab.721a00ac"
scn_major = 0xab
scn_minor = 0x721a00ac

Dec 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: neutrinman | last post by:
why does the following error occur? def quit_time(): data_file = shelve.open("data.dat", "c") data_file = datetime.datetime.today() print data_file raw_input("enter") Traceback (most...
0
by: piyushc | last post by:
Hi, I am having problem creating new project using VS.Net 2003. Whenever I am trying to create new project (any type) it shows error message "Error writing the project file. Error loading...
0
by: Erwan | last post by:
I have a strange (but very blocking) result when using the smtpmail class from an ASPX page : here is the (very simple !) code... '-------------------------------------------------- mail.To =...
1
by: Omatase | last post by:
Here is my code: CDO.Message iMessage = new CDO.MessageClass(); string sFrom; string sDate; iMessage.DataSource.Open(bstrURLItem,null, ADODB.ConnectModeEnum.adModeRead,...
1
by: Paul E Collins | last post by:
I'm using XmlSerializer.Serialize method from System.Xml.Serialization on one of my own classes and getting the following error: "An unhandled exception of type 'System.InvalidOperationException'...
1
by: madushan | last post by:
hi all, once i try to generate .cs file by using the aximp.exe tool it gives the error the command I used: C:\Documents and Settings\malik\Desktop\tt>aximp SHDocVw.dll...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
3
by: walex | last post by:
Hello guys, I'm trying to install devsec an application for ffpeg for camera,but on,is a c programme,after compilation ,i now type make, then this two error are generated.common.h:67: error: array...
3
by: ravisc | last post by:
Hi, I had .Net 2005 framework installed in my system. I had uninstalled the same. Now I have been working with .Net 2003 develpment environment. when I try to debug any .Net 2003 project, it gives...
1
by: Greg (codepug | last post by:
Solution Note: I am experimenting with an excellent popup calendar I found on the Allen Browne web site. I was receiving the following error (Error 13: Type mismatch) when clicking a button...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.