char ch;
filename += ".save";
fstream savefile;
savefile.open(filename.c_str(), ios::out);
int i2 = text_save.length(); //the editor sais this couldn't be done :?
for (int i = -1; i < i2; i++);
{ ch = text_save[i]; //here should be a fault too
savefile.put(ch);
}
conversion from 'size_t' to 'int', possible loss of data
I want to convert a string to an old c-string... But how I tried doesn't work and text_save.c_str(); doesn't work either when I use it, please can someone help me?
Thanx in advance
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
This is an unsigned integer type used to represent the sizes of objects. The result of the sizeof operator is of this type, and functions such as malloc (see Unconstrained Allocation) and memcpy (see Copying and Concatenation) accept arguments of this type to specify object sizes.
Usage Note: size_t is the preferred way to declare any arguments or variables that hold the size of an object.
In the GNU system size_t is equivalent to either unsigned int or unsigned long int. These types have identical properties on the GNU system and, for most purposes, you can use them interchangeably. However, they are distinct as data types, which makes a difference in certain contexts.
For example, when you specify the type of a function argument in a function prototype, it makes a difference which one you use. If the system header files declare malloc with an argument of type size_t and you declare malloc with an argument of type unsigned int, you will get a compilation error if size_t happens to be unsigned long int on your system. To avoid any possibility of error, when a function argument or value is supposed to have type size_t, never declare its type in any other way.
And one more thing. Don't start you loop from -1, because this way it will try to read for a -1 place of string which will crash your program for 99%.
The way I'm reading that is that when you get input from the user, only the first word that is typed is put into the string...... right??
Well, my help is based on that.
When you get input, different functions do it different ways. Eg. Std C function 'scanf' , when specified to input a string, it only takes the first word if any more are input, because it ignores everything past a whitespace (tab, space, newline).
There are different functions in Std C (only making example here, go look for some C++ ones, or you could use these) that are used for input, like scanf, but take everything including whitespaces, so, for the typed string "hello how are you today?", 'scanf' would only get "hello", but another function, like 'fgets' would get "hello how are you today?" but with a newline at the end.
So, just look around, there could be some in the irrlicht API, or probably just go looking in the C++ help for "input string functions" or something like that.
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
OK, the problem is with cin. Try to use filename with space like "name of a file" and you'll see what's wrong. But i don't know how to help you other then using something diffrent to read from keyboard.
the problem isnt cin but filename.c_str() when using space in the filename'
I don't mean the get, but the put().... het writes only one word in the file. Using the cin will result in a string (include words after white space) that string will be converted to a c string witch result in a stop after the first wite space
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP