Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Struggling through the "C" Summary: get Kochan's book Message-ID: <97113@sun.Eng.Sun.COM> Date: 1 Apr 89 02:07:43 GMT References: <12000@louie.udel.EDU> Sender: news@sun.Eng.Sun.COM Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 36 In article <12000@louie.udel.EDU> (Rob Lizak Jr.) writes: > FOR I=1 TO LEN(A$) > PRINT MID$(A$,I,1); > NEXT I C equivalent might be more syntactically written as for (i=0; i < strlen(a); i++) printf("%c", a[i]); Get a copy of the book "Programming in C" by Stephen G. Kochan, ISBN 0-8104-6261-3, it has a good discussion of strings. >no matter what I put for the declaration... it wouldnt work! I added this >to the program to try to make it work... whats wrong with this? char *a; /* This is a pointer to a string */ char a[80]; /* this is a pointer to a string with 80 bytes allocated */ Outside of a function you can declare : char *a = "this is a test string."; /* the auto allocates space */ -or- char a[80]; /* Global variable */ main() { char b[80]; /* Local variable */ /* this copies a string into your string buffer a */ strcpy(a,"this is a test string"); strcpy(b,a); /* Copy string a into string b */ } ----- --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you. "A most excellent barbarian ... Genghis Kahn!"