home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13094 < prev    next >
Encoding:
Text File  |  1992-08-31  |  1.4 KB  |  53 lines

  1. 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
  2. From: kpearce@magnus.acs.ohio-state.edu (BULLDAWG)
  3. Newsgroups: comp.lang.c++
  4. Subject: sscanf?  What am I doing wrong?
  5. Message-ID: <1992Aug31.154723.15839@magnus.acs.ohio-state.edu>
  6. Date: 31 Aug 92 15:47:23 GMT
  7. Sender: news@magnus.acs.ohio-state.edu
  8. Organization: The Ohio State University
  9. Lines: 41
  10. Nntp-Posting-Host: bottom.magnus.acs.ohio-state.edu
  11.  
  12. Hi:
  13.  
  14.     Forgive me if this is a stupid question:
  15.  
  16. I am using Borland C++ and am compiling as default C file.
  17.  
  18. Why doesn't this work?
  19.  
  20. char command[80]  \* This is data from a file read off of the disk 'r' type.*\
  21. char partA[20];   \* and is for example "transmit data" *\
  22. char partB[60];
  23. char tran[] = "transmit"
  24. sscanf(command,"%s %s",partA, partB);
  25.  
  26. void main(void)
  27. {
  28.   if (partA==tran)
  29.   {
  30.       printf("We have a match\n");
  31.   }
  32.   else
  33.   {
  34.       printf("failed again  :(  \n");
  35.   }
  36. }
  37.  
  38. This always fails.  I have tried putting \r\0 and various other control
  39. characters at the end of the ttest string tran[] to no avail.
  40.  
  41. Putting a printf("%s\n %s\n %s\n",command,partA,partB) yields the correct output
  42. e.g.
  43.     transmit data
  44.     transmit
  45.     data
  46.  
  47. So what am I doing wrong?  As far as the program goes they don't match.  But I
  48. say they do.
  49.  
  50. Please e-mail to me.  Thanks.
  51.  
  52. Ken Pearce
  53.