473,491 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SSCANF

Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
mese[2] = anno[4] = '\0';

The values ar random and I don't understand the motive
I tryed either this variant :

char* porka_vakka = strchr(stringa, '/');
*porka_vakka = '\0'; // but either ' ' e '\n'
i_letture = sscanf(stringa, "%s", &mese);

But neither this works...

Could anyone help me ?

Bye
- Atari

p.s. happy new year :)

Jan 3 '06 #1
22 2931

Superfox il Volpone wrote:
Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
mese[2] = anno[4] = '\0';
You have mese[3] and anno[5]. When you read with sscanf you tell it to
store the character arrays in &mese and &anno. mese=&mese[0] and
anno=&anno[0].
It should be: i_letture=sscanf(stringa,"%2s/%4s",mese,anno), otherwise
you are trying to write those values at locations that hold the
addresses of mese and anno instead of writing them to the addresses
where mese and anno point.
If you really want to use & then write:
i_letture=sscanf(stringa,"%2s/%4s",&mese[0],&anno[0]);

The values ar random and I don't understand the motive
I tryed either this variant :

char* porka_vakka = strchr(stringa, '/');
*porka_vakka = '\0'; // but either ' ' e '\n'
i_letture = sscanf(stringa, "%s", &mese);

Same problem as above. Reading into the wrong location.

Jan 3 '06 #2
"Superfox il Volpone" <at***@email.it> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"
"18/2005" is a string literal. Any attempts to modify
any of its characters produces undefined behavior.
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
This gives undefined behavior. You're trying to modify
a string literal.

Also, since 'mese' and 'anno' are arrays, their names
in this context will evalutate to pointers to their
first element. So e.g. use 'mese', not '&mese'.
%s must match with type 'char*'. The expression &mese
does not have that type. Its type is (*)[3] (pointer to
array of three char). Not the correct type.
mese[2] = anno[4] = '\0';
'sscanf()' already applies the string terminator for you
(in the proper location)

Also (disregarding for now the string literal problem)
note that if the size of data stored by 'sscanf()' is
less than the size of the array, your arbitrary placement of
'\0' as the last array element will not terminate the string
properly (there will be 'garbage' between the data and the
terminator).

The values ar random and I don't understand the motive
You don't understand how 'sscanf()' works, or how arrays
and pointers work.
I tryed either this variant :

char* porka_vakka = strchr(stringa, '/');
*porka_vakka = '\0'; // but either ' ' e '\n'
There are two possible results of these two lines, both of
which are undefined behavior:

1) The character '/' is not found in the string (which
causes 'strchr()' to return NULL), in which case you
try to dereference a NULL pointer. Undefined behavior.

2) The character '/' is found (and 'strchr()' returns its
address. You then try to modify it, but it's part of
a string literal. Undefined behavior.
i_letture = sscanf(stringa, "%s", &mese);
More undefined behavior. Attemt to modify string literal.
Wrong data type used with '%s'.

Finally, even if you do have writable storage for 'sscanf()'
note that you have no protection against the data overflowing
your array. Look up the 'width' flag for sscanf() format
specifiers.

But neither this works...

Could anyone help me ?


I think the best advice I can give is to recommend you get
some good textbooks.
http://www.accu.org/bookreviews/publ...ginner_s_c.htm

-Mike
Jan 3 '06 #3
Mike Wahler wrote:
"Superfox il Volpone" <at***@email.it> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"


"18/2005" is a string literal. Any attempts to modify
any of its characters produces undefined behavior.
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);


This gives undefined behavior. You're trying to modify
a string literal.


Look again.
The first parameter of sscanf() is of type const char *
(qualified by restrict in C99 IIRC).

I guess you saw sscanf() and thought sprintf()...

<snip>
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jan 3 '06 #4
Mike Wahler <mk******@mkwahler.net> wrote:
i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
This gives undefined behavior. You're trying to modify
a string literal.


I don't know that OP is "trying" to modify the string literal. In
practice, is sscanf() really likely to modify its first argument?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jan 3 '06 #5
Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Mike Wahler <mk******@mkwahler.net> wrote:
> i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
This gives undefined behavior. You're trying to modify
a string literal.

I don't know that OP is "trying" to modify the string literal. In
practice, is sscanf() really likely to modify its first argument?

Doesn't the prototype of sscanf() promise to *not* modify its first argument?

--
Chris.
Jan 3 '06 #6
Superfox il Volpone a écrit :
I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"
char mese[3]; char anno[5];
These are arrays of char
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
why & ? %s expects exactly what the name of an array of char is : the
address of its first element.

The separator must be read too :

#include <stdio.h>

int main(void)
{
char* stringa = "18/2005";
char mese[3];
char anno[5];
char c;
int i_letture = sscanf(stringa, "%2s%c%4s", mese, &c, anno);

if (i_letture == 3)
{
printf ("'%s' '%s'\n", mese, anno);
}
else
{
printf ("sscanf() error\n");
}
return 0;
}
mese[2] = anno[4] = '\0';


No need for that.

--
A+

Emmanuel Delahaye
Jan 3 '06 #7

"Michael Mair" <Mi**********@invalid.invalid> wrote in message
news:42*************@individual.net...
Mike Wahler wrote:
"Superfox il Volpone" <at***@email.it> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005"


"18/2005" is a string literal. Any attempts to modify
any of its characters produces undefined behavior.
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);


This gives undefined behavior. You're trying to modify
a string literal.


Look again.
The first parameter of sscanf() is of type const char *
(qualified by restrict in C99 IIRC).

I guess you saw sscanf() and thought sprintf()...


Um, yes. Oops. Blush. Sorry. Er, Happy New Year and all that. :-)

-Mike
Jan 3 '06 #8
Mike Wahler a écrit :
char* stringa = "18/2005"


"18/2005" is a string literal. Any attempts to modify
any of its characters produces undefined behavior.


How would it be modified ? I'm curious. Isn't the first parameter of
sscanf() a char const * ?

--
A+

Emmanuel Delahaye
Jan 3 '06 #9
Superfox il Volpone wrote:
Hello

I have some problem with sscanf, I tryed this code but it doesn't works
:

char* stringa = "18/2005" Missing ';' termination char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
mese[2] = anno[4] = '\0'; Unnecessary here: sscanf NUL-terminates the results
The values ar random and I don't understand the motive


Well, it works for me! What makes you think the result is wrong?

Robert
Jan 3 '06 #10

"Emmanuel Delahaye" <em***@YOURBRAnoos.fr> wrote in message
news:43***********************@nan-newsreader-07.noos.net...
Mike Wahler a écrit :
char* stringa = "18/2005"


"18/2005" is a string literal. Any attempts to modify
any of its characters produces undefined behavior.


How would it be modified ? I'm curious. Isn't the first parameter of
sscanf() a char const * ?


Brain malfunction. Read 'sscanf', saw 'sprintf'.
My apologies.

-Mike
Jan 3 '06 #11
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?

The second thing if I want to jump one argument is it correct the
behaviour ?
year[5]
sscanf(str_date, "%*s/%4s", year);

and at last, at year will be placed the string terminator ('\0')

Bye & thx all for the help
~ Superfox il Volpone :)

Jan 4 '06 #12
"Superfox il Volpone" <at***@email.it> writes:
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)
For context, here's the code you posted:

char* stringa = "18/2005"
char mese[3]; char anno[5];
int i_letture;

i_letture = sscanf(stringa, "%2s/%4s", &mese, &anno);
mese[2] = anno[4] = '\0';

Please read <http://cfaj.freeshell.org/google/>.

This also demonstrates why you should always post a small, complete,
compilable program. We can't guess whether the part you didn't post
is what's causing the problem (in this case, it was). What you posted
wasn't even a correct code fragment; the declaration of stringa is
missing a semicolon, an error that the compiler would have caught.
Don't try to re-type your code; copy-and-paste *exactly* what you fed
to the compiler.
I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?
Given, for example,

char anno[5];

the expression "anno", an array name, is implicitly converted (in most
contexts) to a pointer to the array's first element; in this case, the
resulting expression is of type char*. The expression "&anno" yields
the address of the array; the resulting expression is of type
char (*p)[5], i.e., a pointer to an array of 5 chars.

These two expressions are of different types, but they're both
pointers, they both (in some sense) have the same value, and they
*probably* both have the same representation.

Since sscanf() takes a variable number and type(s) of arguments, the
compiler doesn't know what types are expected for the third and fourth
arguments in your call; it just blindly passes in whatever you
specify. It's your job to make sure you call it correctly. Since the
arguments you gave it were (probably) the same size and representation
as the correct arguments, it happened to work. (Passing something of
an incorrect type to sscanf() actually invokes undefined behavior;
working "correctly" is one of the many possible consequences.)

BTW, I believe there are real systems where char* and char (*p)5 would
have different representations, and your sscanf() call would fail.
The second thing if I want to jump one argument is it correct the
behaviour ?
year[5]
sscanf(str_date, "%*s/%4s", year);

and at last, at year will be placed the string terminator ('\0')


Yes, that should work (assuming the declaration is "char year[5]"
rather than "year[5]").

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 4 '06 #13
Chris McDonald <ch***@csse.uwa.edu.au> wrote:
Doesn't the prototype of sscanf() promise to *not* modify its first argument?


I would have sworn that my K&R2 at work gave the type of sscanf()'s
first argument as char*, but I see from n869 that either I or K&R2 am
mistaken. Apologies. It still begs the question of how it can modify
a string literal, however.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jan 4 '06 #14
Christopher Benson-Manica said:
Chris McDonald <ch***@csse.uwa.edu.au> wrote:
Doesn't the prototype of sscanf() promise to *not* modify its first
argument?
I would have sworn that my K&R2 at work gave the type of sscanf()'s
first argument as char*,


It does. It's listed in the errata.
but I see from n869 that either I or K&R2 am
mistaken. Apologies. It still begs the question of how it can modify
a string literal, however.


No, it doesn't beg the question. "To beg the question" means "to assume as
an implicit premise something you are seeking to prove".

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 4 '06 #15
Superfox il Volpone wrote:
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ? No. If mese is an array, then mese and &mese are the same thing.
The second thing if I want to jump one argument is it correct the
behaviour ?
year[5]
sscanf(str_date, "%*s/%4s", year); Yes, if you change your format string to "%*2s/%4s"
and at last, at year will be placed the string terminator ('\0') mese and year will have been terminated with '\0' in any case.
Bye & thx all for the help
~ Superfox il Volpone :)

Jan 4 '06 #16
Robert Harris wrote:
Superfox il Volpone wrote:
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?

No. If mese is an array, then mese and &mese are the same thing.


<snip>

No they are not, they have different types. As a result of this, passing
the wrong one as one of the varidac parameters to sscanf *could* cause
it to fail, although I'm not aware of any implementations on which it
would. The failure could occur if pointer to array of char used a
different representation to pointer to char (say, an implementation
encoded the size of the array in pointer to array of char but not in
pointer to char). It will also cause the compiler to complain at you if
you pass a pointer to array of char to a function expecting a pointer to
char.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 4 '06 #17
Flash Gordon wrote:
Robert Harris wrote:
Superfox il Volpone wrote:
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?


No. If mese is an array, then mese and &mese are the same thing.

<snip>

No they are not, they have different types. As a result of this, passing
the wrong one as one of the varidac parameters to sscanf *could* cause
it to fail, although I'm not aware of any implementations on which it
would. The failure could occur if pointer to array of char used a
different representation to pointer to char (say, an implementation
encoded the size of the array in pointer to array of char but not in
pointer to char). It will also cause the compiler to complain at you if
you pass a pointer to array of char to a function expecting a pointer to
char.

Yes they are. For the array mese passed as a parameter, paragraph
6.3.2.1 of the C standard applies, and I quote:

'Except when it is used as an operand of the sizeof operator or the
unary & operator, or is a string literal used to initialize an array, an
expression that has type "array of type" is convered to an expression
with type "pointer to type" that points to the initial element of the
array object ...'

While for &mese passed as a parameter, paragraph 6.5.3.2 applies:

'The unary & operation returns the address of its operand. If the
operand has type "type", the result has type "pointer to type".'

So they are the same (in the context of being passed as parameters to a
function).

Robert
Jan 4 '06 #18
Robert Harris wrote:
Flash Gordon wrote:
Robert Harris wrote:
Superfox il Volpone wrote:

Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?

No. If mese is an array, then mese and &mese are the same thing.
<snip>

No they are not, they have different types. As a result of this,
passing the wrong one as one of the varidac parameters to sscanf
*could* cause it to fail, although I'm not aware of any
implementations on which it would. The failure could occur if pointer
to array of char used a different representation to pointer to char
(say, an implementation encoded the size of the array in pointer to
array of char but not in pointer to char). It will also cause the
compiler to complain at you if you pass a pointer to array of char to
a function expecting a pointer to char.

Yes they are. For the array mese passed as a parameter, paragraph
6.3.2.1 of the C standard applies, and I quote:

'Except when it is used as an operand of the sizeof operator or the
unary & operator, or is a string literal used to initialize an array, an

^^^^^^^^^^^^^^^^ expression that has type "array of type" is convered to an expression
with type "pointer to type" that points to the initial element of the
array object ...'
So it is still of array type when operated on by the & operator.
While for &mese passed as a parameter, paragraph 6.5.3.2 applies:

'The unary & operation returns the address of its operand. If the
operand has type "type", the result has type "pointer to type".'
So the type above is array of whatever. So the type returned by & is
pointer to array of whatever.
So they are the same (in the context of being passed as parameters to a
function).


No, see above.

The addresses are the same, but the types are not. So, for example, we
get from gcc:
markg@markgordon-lp ~
$ cat t.c
void foo(char *s)
{
}

int main(void)
{
char fred[10];
foo(fred);
foo(&fred);
}

markg@markgordon-lp ~
$ gcc -ansi -pedantic -O t.c
t.c: In function `main':
t.c:9: warning: passing arg 1 of `foo' from incompatible pointer type

markg@markgordon-lp ~
$ cat tt.c
void foo(char *s)
{
}

int main(void)
{
char fred[10];
foo(fred);
/* foo(&fred); */
}

markg@markgordon-lp ~
$ gcc -ansi -pedantic -O tt.c

markg@markgordon-lp ~
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 4 '06 #19

Robert Harris wrote:
Yes they are. For the array mese passed as a parameter, paragraph
6.3.2.1 of the C standard applies, and I quote:

'Except when it is used as an operand of the sizeof operator or the
unary & operator, or is a string literal used to initialize an array, an
expression that has type "array of type" is convered to an expression
with type "pointer to type" that points to the initial element of the
array object ...' meaning
char *var
and
char var[]
are considered the same in this case. It does not say char var[] is the
same as char *var[].

While for &mese passed as a parameter, paragraph 6.5.3.2 applies:

'The unary & operation returns the address of its operand. If the
operand has type "type", the result has type "pointer to type".' Exactly.
If the operand has type the result has type *type, thus:
char argv[] -> char *arg[]
So they are the same (in the context of being passed as parameters to a
function).

No

Jan 4 '06 #20
In article <dj*******************@fe1.news.blueyonder.co.uk >
Robert Harris <ro*************@blueyonder.co.uk> wrote:
... If mese is an array, then mese and &mese are the same thing.


In much the same way that 3 and 3.141592653589793 are "the same
thing", i.e., they compare equal when converted to some particular
common type (int, in this case).

The problem is that "&mese" has the wrong type. It is hard to
compare two values of different types (are 3 and 3.14 equal?); the
first step in such a comparison is to choose some additional type
-- perhaps one of the original two, or perhaps a third -- and
convert all the values to the same type, after which they can
finally be compared.

In the case of 3 and 3.14, if the type chosen for comparison is
"int", they are equal. If the type chosen for comparison is
"double", they are not equal. So 3 and 3.14 are equal, and yet
are also not equal.

I use the above example to make it clear that it is not sufficient
to find *a* type under conversion to which comparison shows the
original values as equal: while (int)3 == (int)3.14, I think most
people would say that 3 and 3.14 are *not* equal, and indeed,
(double)3 != (double)3.14.

You would have a much stronger case if you could prove that, for
some large set of C types \elem T, (T)mese == (T)&mese; but I think
this is impossible to prove in "Standard C Virtual Machine", due
to lack of information. (It actually happens to be true on many
real machines, if only because so many real machines have only one
hardware "pointer" type, or at least, only one that is used by C
compilers. The test is more interesting -- not a "degenerate case"
as a mathematician might put it -- when performed on machines with
actual different hardware pointer types, such as a Data General
MV/10000, or a 1960s PR1ME, or some such.)

In any case, Standard C permits an 80x86 C compiler to pass mese
(or &mese[0]) in a register, but put &mese on the stack (or vice
versa), simply because the types differ. If an 80x86 C compiler
did this, calls using the wrong type would in fact fail, even on
the ordinary 80x86. (In this particular case, &mese[0] has type
(char *), but &mese has type (char (*)[5]).)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Jan 4 '06 #21
Flash Gordon <sp**@flash-gordon.me.uk> writes:
Robert Harris wrote:
Superfox il Volpone wrote:
Sorry people, what I posted it's part of a more large program and the
printf with I verified it was wrong :)

I solved but I don't understand one thing :
the sscanf works with '&mese' and 'mese' in the correct manner : maybe
it's the compiler (GCC) that does some correction ?

No. If mese is an array, then mese and &mese are the same thing.


<snip>

No they are not, they have different types. As a result of this,
passing the wrong one as one of the varidac parameters to sscanf
*could* cause it to fail, although I'm not aware of any
implementations on which it would. The failure could occur if pointer
to array of char used a different representation to pointer to char
(say, an implementation encoded the size of the array in pointer to
array of char but not in pointer to char). It will also cause the
compiler to complain at you if you pass a pointer to array of char to
a function expecting a pointer to char.


Perhaps more realistically, byte pointers could be bigger than word
pointers. This could happen on a system where native machine
addresses point to words, and the C implementation needs a word
pointer and an offset to refer to a byte within a word. (The C
implementation for Cray vector machines *almost* does this, but it
puts the offset into the otherwise unused high-order bits of the word
pointer, so a pointer to the first byte of a word still happens to
have the same representation as a pointer to the entire word.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 4 '06 #22
Flash Gordon wrote:
Robert Harris wrote:

<snip>

No they are not, they have different types. As a result of this,
passing the wrong one as one of the varidac parameters to sscanf
*could* cause it to fail, although I'm not aware of any
implementations on which it would. The failure could occur if pointer
to array of char used a different representation to pointer to char
(say, an implementation encoded the size of the array in pointer to
array of char but not in pointer to char). It will also cause the
compiler to complain at you if you pass a pointer to array of char to
a function expecting a pointer to char.


Yes they are. For the array mese passed as a parameter, paragraph
6.3.2.1 of the C standard applies, and I quote:

'Except when it is used as an operand of the sizeof operator or the
unary & operator, or is a string literal used to initialize an array, an


^^^^^^^^^^^^^^^^
expression that has type "array of type" is convered to an expression
with type "pointer to type" that points to the initial element of the
array object ...'

So it is still of array type when operated on by the & operator.
While for &mese passed as a parameter, paragraph 6.5.3.2 applies:

'The unary & operation returns the address of its operand. If the
operand has type "type", the result has type "pointer to type".'

So the type above is array of whatever. So the type returned by & is
pointer to array of whatever.
So they are the same (in the context of being passed as parameters to
a function).

No, see above.

The addresses are the same, but the types are not. So, for example, we
get from gcc:
markg@markgordon-lp ~
$ cat t.c
void foo(char *s)
{
}

int main(void)
{
char fred[10];
foo(fred);
foo(&fred);
}

markg@markgordon-lp ~
$ gcc -ansi -pedantic -O t.c
t.c: In function `main':
t.c:9: warning: passing arg 1 of `foo' from incompatible pointer type

Sorry, You're right.

Robert
Jan 4 '06 #23

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

Similar topics

7
473
by: Allan Bruce | last post by:
If I have sscanf("FL:%s:%d:%s\n", lGuid, &lID, lFileName); and the last string contains spaces, e.g. my complete string "FL:1234ABCD:3:FileName With Spaces.txt\n" does sscanf just make...
4
4222
by: smshahriar | last post by:
Hi, I want to scan from the following string all the hex numbers and populate an array of integers: 0x27 0x00 0x30 0x00 0x33 0x00 0x36 0x00
10
5413
by: baumann | last post by:
hi, 1) first test program code #include <stdio.h> int main(void) { char * file = "aaa 23 32 m 2.23 ammasd"; int i2,i3;
4
2014
by: baumann | last post by:
hi all there has 2 program 1) the first test program code #include <stdio.h> int main(void) {
5
6390
by: jchludzinski | last post by:
I'm using strtok() to parse thru a line and read different numbers: float value; char *token; token = strtok( line, " " ); .... sscanf( token, "%f", &value ); These results are less...
8
2372
by: Artemio | last post by:
Dear folks, I need some help with using the sscanf() function. I need to parse a string which has several parameters given in a "A=... B=... C=..." way, and each has a different type (one is a...
20
21400
by: AMP | last post by:
Hello, Anybody know if anything exists like sscanf in c. I found a few things OL but most were pretty old. Maybe something has come along since 2004? Thanks Mike
5
3484
by: Alex Mathieu | last post by:
Hi, using sscanf, I'm trying to retrieve something, but nothing seems to work. Here's the pattern: SS%*sþ0þ%6s Heres the data: SS000000395000000000DC-þ0þ799829þ1174503725þ Actually, I...
7
11606
by: gio | last post by:
suppose I have: .... char str1; char str2; int ret; fgets(str1, LEN, stdin); //str1 can contain just '\n' and '\0' ret=sscanf(str1, "%s", str2); ....
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.