| delorie.com/archives/browse.cgi | search | 
| Message-ID: | <35170E30.C1C0EA37@ipass.net> | 
| From: | Terry <iceman AT ipass DOT net> | 
| MIME-Version: | 1.0 | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Re: ? Functions recieving strings? | 
| References: | <0p5jA0_00YUt1EQ0c0 AT andrew DOT cmu DOT edu> | 
| Lines: | 33 | 
| Date: | Tue, 24 Mar 1998 01:36:05 GMT | 
| NNTP-Posting-Host: | 207.120.205.191 | 
| NNTP-Posting-Date: | Mon, 23 Mar 1998 20:36:05 EST | 
| Organization: | iPass.Net | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
James W Sager Iii wrote:
> 
> 
> I'm having a serious trouble in programming.
> I'm passing a string to a function and the function isn't
> always getting the correct string...
> 
> 
> Ie (Not exact example):
> #include "iostream.h"
> void function1(char *my_string);
> void function2(char my_string[]);
> 
> void function1(char *my_string)
> {
> cout<<mystring<<endl;
> }
> 
> void function2(char my_string[])
> {
> cout<<mystring<<endl;
> }
> 
> void main(void)
> {
> function1("Print me");
> function2("Print me too");
> }
> 
> 
> And instead of getting
> Print me
> Print me too
> I'd get something random like
> Hello.
> PCX
> 
> Now that isn't the exact example. The code I have is too complex to post
> as its over 100k in length.  I thought it was just a problem with
> turbo c, but I have hit these errors with Djgpp too.  I'm exasperated
> as I just want my functions to recieve the correct values so I can
> finish my game in a few days...  My only guess is that there is a
> pointer error or something elsewhere in the code.  Any suggestions
> how I would go about tracking down the problem would be more than
> appreciated.
I tried your example and it worked for me.  What command line 
options are you using when you compile?  
Terry
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |