🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.djgpp
3 messages
3 total messages Started by informix Fri, 29 Dec 1995 06:20
is there something wrong with this?...
#4
Author: informix
Date: Fri, 29 Dec 1995 06:20
17 lines
774 bytes
...
	while((fgets(temp,120,fp))!=NULL) {
		sscanf(temp,"%s:%s:%*s:%*s:%*s:%*s:%*s",sent[x].name,
			sent[x].passwd);
		++x;
	}
...

	this was meant to read a unix password file (/etc/passwd) and
	extract the username and encrypted password field...

	can someone tell me why this is not working as planned?... it worked
	on a shitty compiler... i recently installed djgpp...

	should i be doing to a better way?... is it portable?...

Ron!
Re: is there something wrong with this?...
#5
Author: Kurt Watzka
Date: Fri, 29 Dec 1995 11:19
36 lines
1545 bytes
oracle@veenet.value.net (informix) writes:

>...
>	while((fgets(temp,120,fp))!=NULL) {
>		sscanf(temp,"%s:%s:%*s:%*s:%*s:%*s:%*s",sent[x].name,
>			sent[x].passwd);
>		++x;
>	}
>...

>	this was meant to read a unix password file (/etc/passwd) and
>	extract the username and encrypted password field...

>	can someone tell me why this is not working as planned?... it worked
>	on a shitty compiler... i recently installed djgpp...

The "%s" format string does not imply that a colon is not part of a 
"string". You probably want something like

   while (fgets(temp,120,fp)) {
      if (2 != sscanf(temp,"%[^:]:%[^:]",sent[x].name, sent[x].passwd))
         printf("error in line %d\n", x + 1);
      ++x;
   }

>	should i be doing to a better way?... is it portable?...

If you want to use C, and not a language that was designed for this kind
of work, you can use scan sets. They are portable, as long as you have
an ANSI C compiler.

Kurt
--
| Kurt Watzka                             Phone : +49-89-2180-6254
| watzka@stat.uni-muenchen.de
| ua302aa@sunmail.lrz-muenchen.de
Re: is there something wrong with this?...
#11
Author: Graham Broadbridge
Date: Wed, 10 Jan 1996 09:45
13 lines
1068 bytes
: 	can someone tell me why this is not working as planned?... it worked
: 	on a shitty compiler... i recently installed djgpp...

: 	should i be doing to a better way?... is it portable?...

Why not just use the getpwent() function?

--
+----------------------------------------------------------------------------+
  Graham Broadbridge        Internet <graham@peachy.apana.org.au>
  Marsfield   NSW                    <vk2yui@amsat.org>
  Australia                 amprnet  <vk2yui@gw.vk2yui.ampr.org>
+----------------------------------------------------------------------------+
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads