home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!magnus.acs.ohio-state.edu!kpearce
- From: kpearce@magnus.acs.ohio-state.edu (BULLDAWG)
- Newsgroups: comp.lang.c++
- Subject: sscanf? What am I doing wrong?
- Message-ID: <1992Aug31.154723.15839@magnus.acs.ohio-state.edu>
- Date: 31 Aug 92 15:47:23 GMT
- Sender: news@magnus.acs.ohio-state.edu
- Organization: The Ohio State University
- Lines: 41
- Nntp-Posting-Host: bottom.magnus.acs.ohio-state.edu
-
- Hi:
-
- Forgive me if this is a stupid question:
-
- I am using Borland C++ and am compiling as default C file.
-
- Why doesn't this work?
-
- char command[80] \* This is data from a file read off of the disk 'r' type.*\
- char partA[20]; \* and is for example "transmit data" *\
- char partB[60];
- char tran[] = "transmit"
- sscanf(command,"%s %s",partA, partB);
-
- void main(void)
- {
- if (partA==tran)
- {
- printf("We have a match\n");
- }
- else
- {
- printf("failed again :( \n");
- }
- }
-
- This always fails. I have tried putting \r\0 and various other control
- characters at the end of the ttest string tran[] to no avail.
-
- Putting a printf("%s\n %s\n %s\n",command,partA,partB) yields the correct output
- e.g.
- transmit data
- transmit
- data
-
- So what am I doing wrong? As far as the program goes they don't match. But I
- say they do.
-
- Please e-mail to me. Thanks.
-
- Ken Pearce
-