Remember, you're using managed C++, so you need to use managed types.
String^ ba = "41516.7095211088";
Double bb = Convert::ToDouble( ba );
Int32 rounded = (Int32)Math::Round( bb );
MessageBox::Show( rounded.ToString() );
Remember, you're using managed C++, so you need to use managed types.
String^ ba = "41516.7095211088";
Double bb = Convert::ToDouble( ba );
Int32 rounded = (Int32)Math::Round( bb );
MessageBox::Show( rounded.ToString() );
Yes, merge them, all you have to do as far as i know is rename the second form to "Form2" and copy it to the first project. Once you've done that, linking them together isn't too hard.
Try that first.
That is what I thought you were going to say. Please check your facts before turning people off to a good compiler. Turbo C++ has an up-to-date version from around 2006. As far as I know, it conforms to the standard. If you are going to bash Turbo C++, at least make it clear what version you are attacking and why.
Most of the people who use Turbo C/C++ do so because they want to make use of old headers like graphics.h. and FYI I wasn't bashing, he asked which one he should use and even if Turbo C++ is now compliant to the standard, I would still have said MSVC++ for reasons such as the debugger.
Why not?
It's ancient and there's just so many reasons to use an up-to-date compiler, can't be bothered listing them.
Don't use Turbo C, I would go for Microsoft Visual C++.
Tutorial to get you started on windows programming. [link]
If it's an std::string, do mystr.c_str() to get a character array, to access an individual character, do mystr[[B]charIndex[/B]]. This is all over the web, try searching first.
Does it mean that fstream does not include iostream, or is it specific to g++ compiler.
One windows header file usually includes 10/15 others, you can never be sure if it's included until you check. Besides, there's no harm in putting #include<iostream> again, that's what header guards are for.
g++ did not compile this and says that there is no matching call for the last statement. Isn't there a constructor in the class ofstream which accepts a string object as argument?
ofstream doesn't take an std::string as an argument, it has to be a const char*. Here's your fixed code:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void do_something()
{
string fname;
cin >> fname;
ofstream fout(fname.c_str());
// Do stuff with fout
}
int main()
{
do_something();
}
If you want to 'copy' the string into a character buffer, you have to do something along the lines of:
char *newStr = new char[str.length()+1];
strcpy( newStr, str.c_str() );
// Deal with newStr
delete[] newStr;
You clearly didn't search hard.
str.c_str() // returns a constant pointer to its characters
If you're curious, test it on your own computer :P
I just did, and it did exactly what I said it would.
Damage? I doubt it. The physical memory would quickly run out, and then your pc would automatically free all the memory you allocated when you restart the pc or somehow close it.
You didn't use code-tags, even though there's a big button saying code.
Put more effort into making your question presentable, and I'll take a look at the code for you.
Due to your bad formatting, you can't even tell that it's entering an infinite loop on line 10.
Here's your corrected code.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string dude;
bool repeatit=true;
while (repeatit == true) {
cout << "Are you happy?\n";
cin >> dude;
if (dude == "yes") {
cout << "\nYay!";
repeatit = false;
}
if (dude == "no") {
cout<<"\nNo, you're happy. Try again.\n";
}
if (dude != "yes" && dude != "no") {
cout<< "\nAnswer in yes or no only.\n";
}
}
cin.ignore();
cin.ignore();
}
Hope this helps.
Turn off the computer? Just an idea.
On Visual Studio, you do this:
1. To the right green "run" button, set the compile state to "Release"
2. Go to the menu "Project -> (project name) properties"
3. Under "Configuration Properties -> C/C++ -> Code Generation", set "Runtime library" to "Multi-threaded (/MT)"
This is what I found to be the most portable configurations.
It means it's an unsigned integer, to match the type of value.
Found from the web:
u8 unsigned byte (8 bits)
u16 unsigned word (16 bits)
u32 unsigned 32-bit value
u64 unsigned 64-bit value
s8 signed byte (8 bits)
s16 signed word (16 bits)
s32 signed 32-bit value
s64 signed 64-bit value
There's more, but I'm sure you get the picture.
I cant place code here, becasuse this happens in more than one diferent project. When processor is 100 % working, icon is not shown and that's the problem. I found that it is problem with microsoft. I am only interested id someone does not figured it in his own way
Maybe you're doing it wrong in every project?
Is there too much code to post the whole thing, so i can try and compile exactly what you've got? I'm sure I could solve it if i could compile it.
For example, the code to send CTRL-G is this:
keybd_event(VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(71, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(71, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
Hope this helps.
Thanks a lot. :)
I'm still having a few minor problems tho'.
I need to send a ctrl+g
SendMessage ( hndDesigner, WM_KEYDOWN, 17, 1) ; SendMessage ( hndDesigner, WM_KEYDOWN, 71, 1) ; SendMessage ( hndDesigner, WM_KEYUP, 71, 0xC0000001 ) ; SendMessage ( hndDesigner, WM_KEYUP, 17, 0xC0000001 ) ;
17 = control
71 = 'g'Doesn't work?
I uses a spy so I'm sure that I have the right handle, but nothing happens :/Any ideas?
Thanks,
- Henning
Instead of sending a message to press a key, try actually simulating a keypress or mouse click to achieve the same result, research mouse_event and keybd_event.
*Yawn*
Once again, instead of saying what not to do or what's wrong in his program, tell him how to do it right, then we all might actually think you know something for once. Otherwise, just go away, your "help" is needed here.
or *Isn't, should I say :P
Don't copy MSDN doc.
And it's not the right method (events)
*Yawn*
Once again, instead of saying what not to do or what's wrong in his program, tell him how to do it right, then we all might actually think you know something for once. Otherwise, just go away, your "help" is needed here.
You're shouting again, and i don't understand your question.
Pretty much anywhere in your game loop, if you want an exact position, I would put it directly before the lines:
// Animation Control - compute the location for the next refresh
xPos += xSpeed;
yPos += ySpeed;
This code is running good ... but I'm unable to make the ball fall down.
Plz tell what changes i should make to create gravity effects???
Constantly increment ySpeed by however strong you want the gravity to be.
Somewhere in your game loop, try:
ySpeed += 0.5f;
or a value of your choice (better stored as a constant variable).
Okay, you clearly didn't write that code, so before you go any further, do you actually understand any of this or have a knowledge of OpenGL at all? if not, read a book or tutorial first then give it a shot.
i want to detect collision of a circle with the lines(which may be in slope), and after collision the circle should bounce in a paricular direction.....
If you want to bounce off an angled surface, your problem requires some physics, so unless you really know your stuff, don't consider this an easily achievable task.
You can't use an array for a sudoku program? I would have thought that you would have been taught arrays before being told to make something like this.
Anyway, considering there's only 16 cells in the sudoku, just make 16 integers and continue from there.
push_back is a function that belongs to std::vector, anything you do to an array has to be done manually.
You could fill each box with unique integers, shuffle them around (while making sure the sudoku is still valid) and then erase a few of the numbers (making sure it's still possible to solve).
There's probably quite a few ways to manage this, and there's plenty of information on the net to help you.
>dont you think this is a motivator?
Not so much for me, I get my motivation simply because... I like helping people, it makes me feel good :D
I pay absolutely no attention to solved threads, because I agree, it doesn't work very well. Getting a badge isn't important for most members either, and maybe you should think why you are really here - to get help or give help.
Consider being a featured poster/coder a reward, you're lucky to get one, you're not entitled to one because you think you deserve it.
@William. Serkan asks something politely, doesn't he? and your reply is somewhat harsh please don't offense people. everyone in the community is part of it, you == me == Serkan == Salem == Dani, no one can let this community stand up without others help, if anyone criticize me it doesn't mean I'm good or bad, it means how others see me and should take his words in my consideration and I debate this is the best thread Serkan wrote not because the subject has my name, I don't care but what I need to say don't offense someone did dozen of threads marked as SOLVED and when he ask and no one answers he posts the full answer + sample application.
I don't see how my post was harsh, and i'm not saying we don't deserve credit for good posts, but requesting for your friends to be featured shows you're more interested in a badge rather than just helping.
>if my best friends dont get featured i am going to organize them to leave for a better c# forum where their skills are appreciated.
Oh please, do you actually care about helping people or do you just want everyone to see you as somebody who helps people, there's a difference.
>All i care about is becoming Super Mod.
I think I have more chance of watching hell freeze over than seeing you become a super mod. :D
If you really want a better chance of getting some (good) popularity, be nice and helpful, and stop requesting.
I think it's a good idea, in the past i've just given links to images, but it would be much better to be able to attach them.
In this one for example [link]
He didn't do anything "wrong" as such, but there isn't any need to cast it.
>There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.
Huh? A class in C ??:P
It's practically the same thing, in my example I used a struct anyway.
There's plenty of big-number libraries on the net, or if you have the programming ability, you can write your own big-number class.
struct BigInt {
// ...
};
int main( void ) {
}
>William, I wasn't trying to put you down
I didn't assume you were ;)
What I meant is I wouldn't want to have to learn a new language or keep up with all the latest languages constantly. Perhaps a job that requires low level hardware programming would be easier, I'm not saying you wouldn't need to learn anything new, but i'm sure it would be easier.
I just want to have a life as well, is that too much for a programmer to ask for?.. :( Heh, I'm sure i'll think up something.
I don't feel exhausted by learning new stuff, but for me it's not really such an obligation. I'm still in school and do have some free time on my hands which I try to never waste. Admittedly I haven't really learnt anything "new" on the computer recently, especially now that i'm on holiday :P But I do try to do a variety of things, like learning the piano, the japanese language (which is really quite time consuming), play icehockey, and be with my friends when I can. :icon_lol:
I know it does feel like alot of effort to keep up sometimes, but if you can't cope with it, perhaps it's time for you to think of something better suited for you. After all, nobody's forcing you to be in this line of work. In fact, if these are the kinds of problems I will face when i'm older, maybe it's time for me to think of a different career for the future. :icon_eek:
Well, unless you're going to add some artificial intelligence to this, simply put a load of predetermined questions / answers in and apply them to an if / switch statement.
Don't worry about it, I get them all the time :D
Ever heard of punctuation?
Anyway, I have to admit, that confused me.
This part: ~(~0 << n)
will make a binary number containing however many 1's you tell it to, for example...
// ~(~0 << n);
0000001b == ~(~0 << 1)
0000011b == ~(~0 << 2)
0000111b == ~(~0 << 3)
0001111b == ~(~0 << 4)
0011111b == ~(~0 << 5)
I don't really understand what this part does: (x >> (p+1-n)
, but maybe somebody else could enlighten both of us.
Why don't you start by giving us a less vague question. What is the program supposed to do? What output are you expecting? Without these details it's hard for us to help.
>Isn't making a smoking section in a restaurant like making a peeing section in a swimming pool?
Not really.
>Why do croutons come in airtight packages? Aren't they just stale bread to begin with?
Nope, croutons are not stale, they are just rebaked bread.
>If Fed Ex and UPS were to merge, would they call it Fed UP?
I doubt it :P
>If it's true that we are here to help others, then what exactly are the others here for?
We are here to live, but life's more pleasant if people help eachother.
Would you mind posting the entire project zipped (with unneeded compiler generated files excluded) so I can run it and take a closer look.
>If it's a class object (see OP), memmove can't move elements correctly!
What do you mean? All memmove does is move memory. So even if you want to use your own class object, it should still work.
#include <iostream>
using namespace std;
struct mystruct {
char text[5];
};
template<typename type>
void removeElement(type a[], int size, int index) {
memmove(
&a[index], // Dest
&a[index + 1], // Source
(size - index) * sizeof(type) // Size
);
}
int main() {
mystruct a[5] = {"a","b","c","d","e"};
int elementCount = 5;
int removeIndex = 2;
removeElement( a, elementCount, removeIndex );
--elementCount; // Short array length
for (int i = 0; i < elementCount; ++i)
cout << a[i].text;
}
>remove class object means call destructor...
I know, but that's why I asked if there was any real need to destruct the element, when you can just you can simply ignore it and shift array elements around without the need of having to free any memory until the very last moment.
Though as you said, I agree that the OP should stick to SDL containers for the reasons you have suggested.
I don't see much need in actually deleting the one element by itself. If you don't need that element, simply ignore it until it's time to completely destruct the array.
If you want to remove an item in the middle of the array, it's easiest to use ArkM's suggestion and use STL containers, but it's a simple task either way. Simply shift each element after the deleted index left by one place, like this:
#include <iostream>
using namespace std;
void removeElement(int nums[], int size, int index) {
memmove(
&nums[index], // Dest
&nums[index + 1], // Source
(size - index) * sizeof(int) // Size
);
}
int main() {
int nums[5] = {1,2,3,4,5};
int numCount = 5;
int removeIndex = 2;
removeElement( nums, numCount, removeIndex );
--numCount; // Shorten array length
for (int i = 0; i < numCount; ++i)
cout << nums[i];
}
This outputs:
1245
I got it working by using:
int c_gen = rand()%3+1; OB *ob1; ob1 = new OB[c_gen];
Thanks again!
Okay, but now you have to be cautious of memory leaks, when you have finished doing stuff with ob1, you MUST free that memory using the delete oeprator, like this:
delete[] ob1;
Hope this helps.
That's because you can not set the size of an array at runtime. If you want do this, research dynamic allocations using the new keyword.
So, are you trying to make the puk bounce when it hits the top or the bottom? If so, simply invert the Y-Velocity like this:
if ( box.y < 0 ) {
yVel *= -1;
box.y = 0;
}
else if ( box.y > curLvlHeight - PUK_HEIGHT ) {
yVel *= -1;
box.y = curLvlHeight - PUK_HEIGHT;
}
Hope this helps.
Nah! keep them, I found this thread amusing :D