home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3223 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  68 lines

  1. Path: news.unicomp.net!rays
  2. From: rays@conline.com (Ray Schmalzl)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Need help with strings in SAS/C
  5. Date: 9 Feb 1996 04:16:05 GMT
  6. Organization: UniComp Technologies International Corp -- Internet Service
  7. Message-ID: <4fehq5$keg@news.unicomp.net>
  8. NNTP-Posting-Host: 204.96.7.68
  9. Keywords: SAS C
  10.  
  11.     Could somebody out there help me with strings in SAS/C? I have a few 
  12. books on C in general, but none of them cover this quite enough. I have two 
  13. problems. The first is getting the function atoi to work right. For example:
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. void main()
  19. {
  20.    char CharOne, CharTwo[]="012345";
  21.  
  22.    CharOne = getch();        // assume typing in a digit here
  23.  
  24.    printf("%c\t",CharOne) ;
  25.    printf("%i\n",atoi(CharOne)) ;
  26.  
  27.    printf("%c\t",CharTwo[3]) ;
  28.    printf("%i\n",atoi (CharTwo[3]) ;
  29. }
  30.  
  31.  
  32. gives me an error message. the only way i can get it to work is to 
  33. declare a third variable as in the following:
  34.  
  35.  
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. void main()
  39. {
  40.    char CharOne, CharTwo[]="012345";
  41.    char CharThree[2]="";
  42.    
  43.    CharOne = getch();        // assume typing in a digit here
  44.  
  45.    printf("%c\t",CharOne) ;
  46.    CharThree[0]=CharOne;
  47.    printf("%i\n",atoi(CharOne)) ;
  48.    
  49.    printf("%c\t",CharTwo[3]) ;
  50.    CharThree[0]=CharTwo[3];
  51.    printf("%i\n",atoi (CharTwo[3]) ;
  52. }
  53.  
  54.  
  55. Is there any way to do what I'm trying to do without declaring that extra
  56. variable? And what is the deal with that "ecpecting char const * found 
  57. char" error?
  58.  
  59.  
  60. The SECOND question I have is: If I have a variable in my program like:
  61.    char MF[]="ABCDEFG";
  62. how can I set up a watch in the Code Probe debugger that will display the 
  63. array as CHARACTERS, and not as hex values??    
  64.  
  65. Thanks in advance,
  66. Ray
  67.  
  68.