www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/08/17:16:20

From: johne AT parallax DOT co DOT uk (John Eccleston)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: example of sscanf function
Date: Fri, 07 Nov 1997 09:36:40 GMT
Organization: Parallax Solutions Ltd
Message-ID: <878895384.528093@red.parallax.co.uk>
References: <345B78DF DOT 53B722B1 AT netcom DOT ca> <Pine DOT OSF DOT 3 DOT 96 DOT 971106161452 DOT 29241A-100000 AT alfa DOT ist DOT utl DOT pt>
NNTP-Posting-Host: red.parallax.co.uk
Cache-Post-Path: red.parallax.co.uk!unknown AT parsnip DOT parallax DOT co DOT uk
Lines: 45
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Tron  wrote:
[Snip]
>examples:
>
>   char Buffer[100];
>   int Inteiro;
>   char Rest_of_Buffer[60];
>
>   void main(void)
>   {
>     sscanf(Buffer, "%s %d %[^\n]", First_arg, Inteiro, Rest_of_Buffer);

The Inteiro variable needs to be prefixed with & in order for the variable
to be accessed by the scanf function.  So the line becomes:

      sscanf(Buffer, "%s %d %[^\n]", First_arg, &Inteiro, Rest_of_Buffer);

The scanf functions require pointers to scalar variables in order to access 
them.

>   }

[snip]
>
>sscanf, scanf and fscanf, they are very powerfull functions... special for
>shells and parsing...
>

Very true.

Cheers

John

________________________________________________________________
Parallax Solutions Ltd.   Tel.: 01203 514522
Stonecourt,               Fax.: 01203 514401
Siskin Drive,             Web : http://www.parallax.co.uk/~johne
Coventry CV3 4FJ          Mail: johne AT parallax DOT co DOT uk
________________________________________________________________
                         Remember:
 There is no such thing as computer error, it's 100% YOUR fault
________________________________________________________________


- Raw text -


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