TIP: Click on subject to list as thread! ANSI
echo: locsysop
to: Roy Mcneill
from: Bob Lawrence
date: 1994-05-30 12:09:24
subject: C

RM> char dest[4];
 RM> char *source = "3:711/934.12";
 RM> char *p;

 RM> p = source + 2;
 RM> strncpy (dest, p, 3);
 RM> dest[3] = "\0";

Hi Roy,
        I'm still not on top of pointers. every time I try to use them
I manage to lock the computer. Why can't I define:

char source[16]
strcpy(source,"3:711/934.12");

and then use 

  strncpy(dest,source[2],3);

 RM> p = strtok (source, ":");  /* find 1st token */
 RM> cout << p << endl;         /* print it */
 RM> p = strtok (NULL, "/");    /* find next token */
 RM> strcpy (dest, p); /*copy it out. p is already
 RM> null-terminated*/ cout << p << endl;         /* etc etc */
 RM> p = strtok (NULL, ".");
 RM> cout << p << endl;

 RM> (a bit of gratuitous C++ thrown in cos I like printf only a bit
 RM> more than scanf...)

  I've learned enough about C++ to let my mind go blank as soon as I
see any part of it, so there was no harm done  ;-). I like printf
because it was the first thing I got to work, but I'm falling in love
with puts and her little sister putc.

Regards,
Bob

 
___ Blue Wave/QWK v2.12

--- PQWK202
* Origin: Precision Nonsense, Sydney (3:711/934.12)
SEEN-BY: 711/934
@PATH: 711/934

SOURCE: echomail via fidonet.ozzmosis.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™.