TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: `C` mavens
from: Jim Peasley 72726,1153
date: 1990-12-02 13:28:11
subject: #`C` problem

#: 8539 S3/Languages
    02-Dec-90  13:28:11
Sb: #'C' problem
Fm: Jim Peasley 72726,1153
To: 'C' mavens

  Anybody want to help save my sanity??
I'm trying to parse out the year from an input string passed to a function,
and can't see where I'm going wrong.
 
 Sample C code :
------------------------------------------------------------------------ 
print_event(Inline)
  char Inline[81];
  {
   int e_yr;
   ...
   ...
   char ev_yr[3];
   char *inptr = Inline;
   ...
   ...
p  strncpy(ev_yr,inptr + 6,2);           /* copy bytes 6 & 7 to ev_yr */
   itoa(e_yr,ev_yr,10);            /* convert int e_yr to char ev_yr base 10 */
   printf("\nEvent year = %s",ev_yr);  <=== always prints "2"
   ...
   ...
------------------------------------------------------------------------ 
 I'm using Turbo C and stepping through the code line-by-line, and still
can't see what's wrong... anybody else see the problem??
 
 BTW - Turbo C is a neato development environment - lots of on-screen help
and it's lightning FAST, but the CoCo C compiler catches some errors that
TC seems to ignore.  
 
 ...Jim

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.