SD> 1. I have this program that always gives me a warning and I was wond
SD> there was a way to get rid of the warning.
SD> #include
SD> main()
SD> {
SD> unsigned char Monster_Name;
SD> Monster_Name = "Bear";
SD> clrscr();
SD> printf("%s", Monster_Name);
SD> getch();
SD> return(0);
SD> }
SD> The warning I get is this :
SD> Warning Nonportable pointer conversion in function main
The declaration of Monster_Name is wrong.
unsigned char Monster_Name[];
or
unsigned char *Monster_Name;
And it's better to directly initialize Monster_Name in its
declaration:
unsigned char Monster_Name[] = "Bear";
And since the characters accessed through Monster_Name aren't
modified, it's better to declare them to be constant:
const unsigned char Monster_Name[] = "Bear";
SD> My next question is how do you use dos commands in C++. I mean if I
SD> make a program that could show all the files in a certain directory,
SD> directories, etc. how would I do this?
You should use a library for this purpose.
SD> My last question is this. How do you save to a seperate file (name
SD> age, other information), and how do you retrieve this information in
SD> program?
Use file streams. For saving a number, use something like:
const int i = 42;
ofstream os("outfile.txt");
os << i;
For reading it:
int i;
ifstream is("outfile.txt");
is >> i;
Thomas
---
þ MM 1.0 #0113 þ Oops... Tried to steal my own tagline!
---------------
* Origin: McMeier & Son BBS (2:301/138)
|