|
hi,
from reading the subject title... its easy... but what i really want to do is this:
say for example...
int a = 1;
int b = 2;
int number = a + b;
int number is therefore 3
HOWEVER... what i want it to do is...
to make int number 12 instead of adding it and making 3. i want the two ints together so it forms an int number of 12.
does anyone know how to do this in c++ please? something to do with strings?
thank u very much.
|
|
|
|
|
Seeing as you're asking in the MC++ forum, just call the ToString() method on the numbers a and b, and you'll get a string which you can convert back into a number.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Another, old school, method is using good ol' sprintf / atoi combo
int nNum1 = 1;
int nNum2 = 2;
char caTempBuf[10];
sprintf(caTempBuf, "%d%d", nNum1, nNum2); //concatination here
int nConcatinated_Number = atoi(caTempBuf);
that should work.
When the going gets tough... write a computer program to do the thing for you
|
|
|
|
|
Or, if you wanted something really old school (and kind of limited) you could do something like the following:
<br />
int a=1, b=2;<br />
char[3] c;<br />
c[0] = a + '0';
c[1] = b + '0';
c[2] = '\0';
cout << c << endl;<br />
but, like I said, this is kind of limited if you're doing anything with bigger or negative numbers.
Democracy for the USA!
|
|
|
|
|
int a = 1;<br />
int b = 2;<br />
int number;<br />
std::stringstream ss;<br />
ss << a << b;<br />
ss >> number;
|
|
|
|
|
Hi all,
I am doing my first setup project for the addin I wrote and can't solve following problem.
I want to deploy an addin for Visual studio. So I need to look in registry for the HKLM\SOFTWARE\Microsoft\VisualStudio\7.X\InstallDir (where 7.X is 7.0 or 7.1) and take it into MyPATH0 and MyPATH1 variables. For the installed version(s) I need to make TARGETDIR to MyPATH0\..\..\\Vc7\VCWizards.
I have no idea how to solve this. Setup wizard seems to have very simple logic, so how can I program in the wizard
"
1.TAKE REGISTRY KEY XX\7.0 into VAR
2. If success Make VAR+AAA to the TARGET DIR
3.Install
4.TAKE REGISTRY KEY XX\7.1 into VAR+AAA
5. If success Make VAR to the TARGET DIR
"
Thank you very much for your help,
Boni
|
|
|
|
|
Im having a little trouble storing the outputs in an array. while the compiler is running i can get the correct output, but cant set up the array for using the results later on. any help would be greatfully appreciated.
What I want in the array is time_of_arrival results from the following function;
CComplexVector process_the_ray(CRay3d a_ray,int m)<br />
{ <br />
CComplexVector result ; <br />
double the_distance ; <br />
int i ; <br />
double length;<br />
<br />
<br />
result = inc_field( (a_ray.listnode(0)).listpoint(),(a_ray.listnode(1)).listpoint(),m ) ; <br />
the_distance = (a_ray.listnode(1).listpoint() - a_ray.listnode(0).listpoint()).abs() ; <br />
<br />
<br />
for( i = 1 ; i < a_ray.non() - 1 ; i++) { <br />
if( a_ray.listnode(i).listtype() == 1) <br />
result = calculate_reflection(result, a_ray.listnode(i-1) , a_ray.listnode(i), a_ray.listnode(i+1) , the_distance) ; <br />
<br />
if( a_ray.listnode(i).listtype() == 2) <br />
result = calculate_transmission(result, a_ray.listnode(i-1) , a_ray.listnode(i), a_ray.listnode(i+1) , the_distance) ; <br />
<br />
<br />
the_distance += (a_ray.listnode(i+1).listpoint() - a_ray.listnode(i).listpoint()).abs() ; <br />
<br />
} <br />
<br />
<br />
length=the_distance;<br />
cout<< "length is:" <<length<<endl;<br />
<br />
time_of_arrival=(length/c);<br />
<br />
cout<<"time_of_arrival:"<<time_of_arrival<<endl;<br />
<br />
return result; <br />
<br />
}
|
|
|
|
|
How do I overload that operator?
I wrote a ref class, and I want to implement [] operator. I tried various ways, without success.
What is the exact synrax?
I Hate MC++.
Thanks.
|
|
|
|
|
I don't use MC++, but the operator signatures for operator[] in
most flavors of C++ is typically as follows:
// return element for read/write
T& operator[](int index);
// return element for read-only
const T& operator[](int index) const;
Hope that was what you were looking for.
|
|
|
|
|
How can I detect a incoming phone call and display the number on the screen using C++ program
If possible send a code
Jack
|
|
|
|
|
Brilliant.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
Hi!
I'm working with Borland C++ Builder 6 and i need to get the mirror of a text; it means that a string has to be flipped. In other words, i don't need only that the characters of a string change order ('mirror' becomes 'rorrim'), but also the single font must be flipped (not using a mirrored font). How can i obtain that? I tried by inverting the order of the pixels of the Canvas in which the text is drawn, but in this way the software get too slow.
Please, give me help!
Thanks a lot
Bye
|
|
|
|
|
Borlard cannot compile managed C++.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm new to managed C++ and I am looking at MCppWrapper, one of the 'Cross-Language Samples' in the help for Visual Studio.NET. It shows how managed C++ can wrap unmanaged C++ and then be used by C#.
Two questions:
- The unmanaged code returns a dynamically allocated char*, which the managed C++ casts to a String*, which the C# uses as a String object. At what point (and how) does the char* become a String object with its properties set, e.g. Length?
- How and when does this char* allocated by unmanaged code get freed? Can the Garbage collector do that?
Thanks!
John Frank
|
|
|
|
|
|
Thank you very much for your reply!
However, from all that I can tell from the code, this is not a case of PInvoke. I am new to Managed C++ so I may be missing something, and I realize that it is hard to answer my questions without having seen the code. I have used PInvoke with C# to use standard Windows DLLs, and MSDN seems to indicate that I would need to do the same thing in C++:
' [C++] Use the DllImportAttribute to identify the DLL and function. Mark the wrapper method or function with extern "C". '
None of this is apparent -- is this somehow happening implicitly?
Regarding the second question: Are you saying that the garbage collector is freeing memory that is allocated by an unmanaged process?
Thanks again!
John Frank
|
|
|
|
|
Hello everyone!
First time I ask a question here but have read many articles and learned a lot....
I have a problem with managed C++ and the Application class, I want to use Application::CommonAppDataPath but the only answer I get is "D:\Documents and Settings\All Users\Application Data\\\1.0.0.0" and I have tried changed the items (alredy present) in assemblyinfo.cpp but to no help.
But I can't figure out what I am doing wrong...
Are there other propeties that need to be changed/added?
Something else I am doing wrong (something is it obviously )?
greetings:
Mårten
|
|
|
|
|
I have been trying for kicks to write a Managed C++ dll to wrap the creation of a system tray icon and those notification balloons.
However I have noticed that the stucture of NOTIFYICONDATA does not match with the version posted on MSDN and is missing the various variables required to to create a the balloons. I have tried updates my platform sdk to no avail. Any suggestions where I could find the correct one or would I have to define it myself?
|
|
|
|
|
Please,
How create a Printer Port Monitor??
I need to create this.
Please help me!!!
raf-sp
|
|
|
|
|
I am using Visual Studio.Net 2003B and I have to say that i am really pleased with
the Studio's Form Designer...It really helps you handle the events ,the properties and many other things.
BUT I have some problems with the organisation of the Forms the Designer proposes(or is it forces you..?).
It implements a form as a Form.h library file and a main CppForm for example .cpp file which calls the
Forms class at the beginning.
Application::Run(new Form1());
Let's say i create a second form using Studio's Wizard,Add New Item->Windows Form.
That means a second Form2.h and a Form2.cpp is created.
What i want to do is by clicking a button at the Form1 to Show Form2..
How do I do that.
Does it have anything to do with PArent and Child Forms?
I found the following code for Child and Parent Forms but the problem is i want to
put this code into the Form1.h event handler for my button..
private:
void CreateMyChildForm ()
{
// Create a new form to represent the child form.
Form* child = new Form();
// Increment the private child count.
childCount++;
// Set the text of the child form using the count of child forms.
String* formText = String::Format( S"Child {0}", __box(childCount));
child->Text = formText;
// Make the new form a child form.
child->MdiParent = this;
// Display the child form.
child->Show();
}
If i want to fire a new instance of Form2 class how would i do it as far as the event handler of Button1 let's say
is in Form1.h and cannot "see" the Form2 class located in Form2.h..
PLS HELP
May it be your fate to live in interesting times
|
|
|
|
|
int APIENTRY _tWinMain(HINSTANCE hInstance,<br />
HINSTANCE hPrevInstance,<br />
LPTSTR lpCmdLine,<br />
int nCmdShow)
Why's it called _tWinMain, instead of WinMain? What does APIENTRY do?
-------------------------------------------
int __stdcall WinMain(int argc, char* argv[])
If __stdcall is to call Win32 API, why can't I use:
int _stdcall WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
--------------------------------------------
When to use which? What are the differences between these two Main function?
Thanks
|
|
|
|
|
|
I am having problems launching MS Word from my code (Visual C++ .net).
I do not need to link to the data in any way - just launch Word with a specified document
|
|
|
|
|
read the FAQ, under 'shellexecute'.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|