|
|
See
<code>
char *Char;
double Double;
Char = " -1234.56";
Double = atof( Char );
CString str;
str.Format("%lf",Double);
whitesky
|
|
|
|
|
If i've got a char vector ( example: char name[30]),
and i want to convert it into a CString,
is there a way to do that ?
|
|
|
|
|
char name[30] = "hello you";
CString str = name;
char name2[30];
strncpy(name2, str, sizeof(name2));
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-- modified at 11:12 Wednesday 19th July, 2006
|
|
|
|
|
toxcct wrote:
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name2 = str[0]; is fine, or char* name2 = str.GetBuffer() , but not the other.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
toxcct wrote: char name2;
strcpy(name2, str);
That still won't compile. You'd have to write it like so:
char name2;
strcpy(&name2, str);
Which is VERY BAD. Since strcpy doesn't check for proper lengths on the source array, it will just start writing to memory at the address (which is the address of a single character) and keep going until its done. That is, it will overwrite at least 1 character in memory that is not allocated for name2 if str is anything but an empty string. I believe what you wanted to show was:
char name2[30] = {0};
strcpy(name2, str);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
-- modified at 10:56 Wednesday 19th July, 2006
|
|
|
|
|
oops, i was meaning char[30] , not only char . and to ensure the length of data copied, strncpy() is the function to use...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Hi,
I load an image and simply display it ..
How can i Zoom on the area of the picture ?!
I can zoom
right now i zoom on the picture with using bigger rect of my source image and just displaying it ...
Is there any technic or special method in GDI+ ?!
I need Faster drawing
|
|
|
|
|
Hi Friends,
How do I find out if the target platform supports 64 bit Arithmetic or not?
I will also like to know about finding if the target platform is Little Endian or Big Endian.
Are ther some compiler switches which help to determine these. The code is mostly C++ code but it needs to be compiled for different platforms.
Thanks in Advance.
Regards.
|
|
|
|
|
Well, VC6++ includes __int64, so you could check
#if defined(_MSC_VER)
#if _MSC_VER >= 1200
// Yup, it's VC6 or later
#endif
#endif
There are different processor type macros, such as _M_IX86 which you can use to determine that it's compiling for X86. There are similar ones supported by (for instance) the ARM compiler for Windows Embedded.
What you need to do is look at the predefined macros like this for each of the compilers you're using for different platforms.
Steve S
Developer for hire
|
|
|
|
|
How do I find out if the target platform supports 64 bit Arithmetic or not
that depends mostly on the compiler. even machines that don't support 64 instructions in hardware can support it in software. ex.: __int64 i; will work wherever MS's C/C++ compiler works.
psychedelic_fur wrote: I will also like to know about finding if the target platform is Little Endian or Big Endian.
int tst=1;
if (((char*)tst)[0])
printf("Low endian");
else
printf("High endian");
Do the chickens have large talons?
|
|
|
|
|
how to read and write in file in case of vs 6.0
|
|
|
|
|
use STL :
std::ifstream and std::ofstream are what you're looking for, in case of C++, fopen() , fread() , fwrite() , fscanf() , fprintf() , fclose() otherwise
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Hi TOXCCT,
I want to create a cpp file template through MFC application. If i specified the class name( TestClass ) the application will automatically create the file TestClass.cpp with some codes like
#include TestClass.h
.
.
.
TestClass::TestClass()
{
}
.
.
.
someComments...etc.
if i want to do the same method or any other method is there????
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
|
if u kno, then please tel me, whether there is any other way to create cpp files
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
|
No problem....
i will use the CFile to create it.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
yes...i also need it
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
if u r using MFC u can use CFile
never say die
|
|
|
|
|
fread and fwrite
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
hey, this is already told by toxcct in better way....then y u reapeating the same one????
If have any other idea then please tel it
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
You could use standard CFile/CStdioFile classes to read/write from/to files.
Here's a good example - Johan Rosengren's CTextFile: A handy helper[^]
|
|
|
|
|
Hi,
When 2 use glPushmatrix() and glPopMatrix() functions
When the goin gets tough then tough gets going
|
|
|
|