|
Hi
How to convert an CString variable to String variable
CString str1;
String ^str2;
How to assing str1 to str2?
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
dtr.GetBuffer() will give you the underlying memory pointer, I assume you can build a String ^ from that.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
String ^str2 = gcnew String(str1);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I'm givin' them away!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
first of all, I post some Codes: (C++/CLI Code)
using namespace System;
enum class TEST
{
TEST1 = 100, TEST2 = 2
};
struct TEST_SET
{
TEST testType;
char* testName;
};
TEST_SET g_Test_Set[2] =
{
{ TEST::TEST1, "TEST1" },
{ TEST::TEST2, "TEST2" }
};
int main()
{
g_Test_Set[0].testType = TEST::TEST1;
g_Test_Set[1].testType = TEST::TEST2;
TEST tEnum = TEST::TEST1;
return 0;
}
tEnum Works, but g_Test_Set[0].testType Doesn't show Value(Error : Cannot obtain value)
that enum , struct must be close to c++(there are plenty of c++ codes like that) , How can it be work?
|
|
|
|
|
Why do all that when you can do this:
using namespace System;
enum class TEST
{
TEST1 = 100, TEST2 = 2
};
int main(array<System::String ^> ^args)
{
TEST t1 = TEST::TEST1;
TEST t2 = TEST::TEST2;
Console::WriteLine(t1.ToString());
Console::WriteLine(t2.ToString());
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I always get y_num=0 when a=16 and b=256 (I want y_num=65536)
Please help.
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
#include <time.h><br />
#include <math.h><br />
<br />
typedef unsigned int WORD;<br />
typedef WORD* WORDPTR;<br />
<br />
WORDPTR *S;<br />
WORDPTR D;<br />
<br />
WORD x_num;<br />
WORD y_num;<br />
<br />
WORD a;<br />
WORD b;<br />
WORD i, j;<br />
int main()<br />
{<br />
puts("------------------ Start --------------------");<br />
puts("");<br />
<br />
a = 0;<br />
printf("Enter a = ");<br />
scanf("%u", &a);<br />
<br />
<br />
b = 0;<br />
printf("Enter b = ");<br />
scanf("%u", &b);<br />
<br />
x_num = 1 << a;<br />
y_num = 1 << b;<br />
<br />
S = (WORDPTR *)malloc(x_num*sizeof(WORDPTR));<br />
if (S == NULL)<br />
{<br />
puts("Error 1!");<br />
return 1;<br />
}<br />
for (i = 0; i < x_num; i++)<br />
{<br />
S[i] = (WORDPTR)malloc(y_num*sizeof(WORD));<br />
if (S[i] == NULL)<br />
{<br />
puts("Error 2!");<br />
return 1;<br />
}<br />
}<br />
<br />
D = (WORDPTR)malloc(y_num*sizeof(WORD));<br />
if (D == NULL)<br />
{<br />
puts("Error 3!");<br />
return 1;<br />
}<br />
puts("OK!");<br />
<br />
return (0);<br />
}
My favorite site:
Vietnam Trading Information
Tour au Vietnam
|
|
|
|
|
AS this is C, it can't be using .NET and therefore you are in the wrong forum. Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The result of '1 << 256' is out range of WORD.
1 << 256 equal to 2^256! 65536 = 2^16
|
|
|
|
|
The result of '1 << 256' is out range of WORD
So what type of variable could solve this problem?
|
|
|
|
|
1 - why aren't you asking in the right forum ?
2 - do you understand what a WORD is ? Tried to google it ? Compared it with other data types to see which seems like it's bigger ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I have written a program to receive date through TCP/IP. I used Socket for that. Actually my program is a server that only listens to clients. Well, the program works fine, if the clients send data gradually, but if a client sends big data packet fast, then my program cannot cope with that speed. Therefore it receives packet #1, and while it is busy doing that, the client may send three more packet meanwhile. Again when my program is ready to receive next packet, it has already missed three packets and receives the 4th packet that the client has sent.
Is there any way to take control of TCP/IP in our hand? I mean a way that when my Listener Server program receives the 1st packet, the TCP cannot send packets anymore until my program asks for a new packet?
Thanks in advance
AlwaysStudent
|
|
|
|
|
This is the C++/CLI managed forum. Are you using the .NET Socket classes? If not this question is in the wrong forum.
If you are using a TCP connection what you are describing does not happen. You must be doing something wrong. Perhaps your analysis of the problem is incorrect or you might even have a bug.
|
|
|
|
|
Yes, it does. My my listener receives data asynchronously.
p.s. I'm using the .NET Socket classes.
AlwaysStudent
|
|
|
|
|
Hi all,
Can u pls tell me how to mount any disk mage file to any folder.
How we can mount any file?pls tell me it is highly obliged me.
Thanks in Advance
Bhaskar
|
|
|
|
|
using Microsoft .NET ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
in C++ i want to mount it?
is it possible
|
|
|
|
|
This is the managed C++ forum, try the Visual C++ forum, where your question will not be off topic.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
Actually i need to create to virtual drive for hard disk. i am trying to fisrt create Disk Image File , then mount this disk image file and use it as virtual drive. Can anybody tell me how to create disk image file or .iso file of any drive.Pls help me. It is highly obliged to me.
Thanks in advance
Bhaskar
|
|
|
|
|
I have used VirtualDrive Pro. It worked very well for me.
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Hi,
I'm working in managed c++ and using windows forms and I'm having a problem with Double::TryParse. At a certain point in my work I need to fill a text box with a number ( a double) and when i use Double::TryParse(textBox->Text, number) (where number is of type double), the number i get isn't the double i want.
For example if i fill the text box with "1.2" the variable 'number' will be 12.0 . However if i fill with "1,2" i get 'number' equal to 1.2 (which is the correct result).
My question is if there is any way to make it parse the number in the format "x.x" correctly.
Thanks.
|
|
|
|
|
Hi, your problem is with number formats and regional settings.
In some countries the decimal point is a period, and the optional thousands separator is
a comma. In other countries it is the other way around. Which one your system uses is
choosen through a Control Panel called Regional Settings on an English Windows XP.
Remark: AFAIK the thousands separator is relevant only for output, the character gets
ignored on input.
A program should follow the regional settings as set in that Control Panel, and that is
what a lot of functions/methods do. Some functions/methods also offer an overload
that allows you to specify some options, but I don't expect you find a way to make
TryParse do the opposite of the Control Panel settings.
-- modified at 12:13 Monday 12th November, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yes.. But what if I run the program in a computer with different regional settings? Would i have to change the settings in the control panel? =/
And, since, in my program, I have the option to fill automaticaly the textBox through a stored double and it fills in the format "x.x", it wouldn't make sense having to manually change the '.' to a ','.
For Example:
I get a value from a robot ( which my program is controlling) and put it in the textBox (Let's say it's 1.5) It is filled in the form as "1.5". Now I want to feed that number back to the robot (nvermind the reason): the double::tryparse method converts it to 15.0, which is wrong. And it wouldn't be very user friendly do go to the textbox and have to manually change the separator to a comma.
But, nevertheless it worked the problem is that i have to change the settings of every computer in which i use this program :s Thanks anyway
-- modified at 12:59 Monday 12th November, 2007
|
|
|
|
|
Hi,
the normal approach is to use the system settings, they should reflect what the user
expects to have (for all applications).
I trust you can supersede the system settings by systematically use our own settings,
through CultureInfo.NumberFormat.CurrencyDecimalSeparator and others. If this fails at
first, try again, I trust you can get it right in the end.
If you decide to have an app that ignores regional settings, in my opinion you should:
- make sure you are consistent in this.
- mention this on every form that is affected.
Some general advice: an app internally should work with the correct data types,
I mean numbers should be stored and processed as much as possible in ints/floats/whatever
and not in strings. Their string representation should be used only:
- on the user interface (at best following the regional settings)
- on device interfaces, such as a robot: according to the interface spec
- for permanent storage: if binary form is not possible/acceptable for some reason,
then a universal string format should be choosen and documented (here you should NOT
follow regional settings).
BTW: Exactly the same problems exist with dates; there are several date formats,
and in some databases they got stored as strings, leading to all kinds of problems
when the data moves around the world, or gets used internationally.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|