delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/29/06:25:06

From: Maxximo <mssmsoft AT my-dejanews DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Integer -> String
Date: Thu, 29 Apr 1999 07:14:16 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 25
Message-ID: <7g90s6$q01$1@nnrp1.dejanews.com>
References: <37267AA1 DOT EA49DE45 AT student DOT cowan DOT edu DOT au> <3727260C DOT E5619CFC AT nochance DOT com>
NNTP-Posting-Host: 138.132.53.11
X-Article-Creation-Date: Thu Apr 29 07:14:16 1999 GMT
X-Http-User-Agent: Mozilla/3.04Gold (X11; I; OSF1 V4.0 alpha)
X-Http-Proxy: 1.0 x8.dejanews.com:80 (Squid/1.1.22) for client 138.132.53.11
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <3727260C DOT E5619CFC AT nochance DOT com>,
  Edward_hill <ha AT nochance DOT com> wrote:
> #include <stdio.h>
>
> int main(void)
> {
>    int myint = 100;
>    char buffer[10];
>
>    sscanf(buffer, "%d", &myint);
>
>    return 0;
> }
>
> return values and such like should be checked.
> Ed

It is wrong!
The sscanf() "read" from the string 'buffer' an integer (because you have used
%d) and stores the value into 'myint', like atoi(), not viceversa.

Maxximo

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019