Xref: news-dnh.mv.net comp.lang.c:49374 comp.os.msdos.djgpp:4084 Path: news-dnh.mv.net!mv!barney.gvi.net!news.netrail.net!arther.castle.net!micro.internexus.net!news.sprintlink.net!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!fu-berlin.de!cs.tu-berlin.de!uni-erlangen.de!lrz-muenchen.de!sun2!ua302aa From: ua302aa AT sun2 DOT lrz-muenchen DOT de (Kurt Watzka) Newsgroups: comp.os.msdos.djgpp,comp.lang.c Subject: Re: is there something wrong with this?... Date: 29 Dec 1995 11:19:47 GMT Organization: Leibniz-Rechenzentrum, Muenchen (Germany) Lines: 36 Distribution: world Message-ID: <4c0isj$oi8@sparcserver.lrz-muenchen.de> References: <4c01cb$nu2 AT veenet DOT value DOT net> NNTP-Posting-Host: sun2.lrz-muenchen.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp oracle AT veenet DOT value DOT 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 AT stat DOT uni-muenchen DOT de | ua302aa AT sunmail DOT lrz-muenchen DOT de