www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/23/23:47:07

From: James W Sager Iii <sager+@andrew.cmu.edu>
Newsgroups: comp.os.msdos.djgpp
Subject: ? Functions recieving strings?
Date: Mon, 23 Mar 1998 18:40:48 -0500
Organization: Junior, MCS Undeclared, Carnegie Mellon, Pittsburgh, PA
Lines: 43
Message-ID: <0p5jA0_00YUt1EQ0c0@andrew.cmu.edu>
NNTP-Posting-Host: po9.andrew.cmu.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

 
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. 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019