|
||
|
|
#1 (permalink) |
|
Forum Expert
|
Hiya, i'm trying to make a little script thingy here, and I can't seem to get Convert.ToInt32() to work. It simply gives me the error(s):
Code:
<filepath here>(49) : error C2065: 'Convert' : undeclared identifier <filepath here>(49) : error C2228: left of '.ToInt32' must have class/struct/union type Code:
int hitsmax = Convert.ToInt32((1 / wep[sub].speed) * 3000); Code:
int hitsmax = (int)((1 / wep[sub].speed) * 3000); What would I have to #include in order to declare Convert.ToInt32? Thanks! -Aiden
__________________
|
|
|
|
|
|
#2 (permalink) |
|
Master of the Internet
Join Date: Oct 2005
Age: 44
Posts: 6,283
|
try
Code:
System.Convert.ToInt32((1 / wep[sub].speed) * 3000); |
|
|
|
|
|
#3 (permalink) | |
|
Forum Expert
|
Quote:
![]() Code:
--------------------Configuration: WeaponArmor - Win32 Debug-------------------- Compiling... WeaponArmor.cpp C:\Program Files\Microsoft Visual Studio\C++ 6.0\MSDev98\MyProjects\WeaponArmor\WeaponArmor.cpp(50) : error C2065: 'System' : undeclared identifier C:\Program Files\Microsoft Visual Studio\C++ 6.0\MSDev98\MyProjects\WeaponArmor\WeaponArmor.cpp(50) : error C2228: left of '.Convert' must have class/struct/union type C:\Program Files\Microsoft Visual Studio\C++ 6.0\MSDev98\MyProjects\WeaponArmor\WeaponArmor.cpp(50) : error C2228: left of '.ToInt32' must have class/struct/union type Error executing cl.exe. Creating browse info file... WeaponArmor.exe - 3 error(s), 0 warning(s) With the calculation done first, the result is the same (good idea though). Tried it as a double and a float. No difference.
__________________
|
|
|
|
|
|
|
#5 (permalink) | |
|
Forum Expert
|
Quote:
Like... so: Code:
C:\Program Files\Microsoft Visual Studio\C++ 6.0\MSDev98\MyProjects\WeaponArmor\WeaponArmor.cpp(13) : error C2873: 'System' : symbol cannot be used in a using-declaration
__________________
|
|
|
|
|
|
|
#9 (permalink) | |
|
Forum Expert
|
Quote:
C++ Example Code:
// Project 1 Cplusplus.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <conio.h>
int main(void)
{
cout<<"HEY, you, i'm alive! Oh and Hello C++ World!" << endl;
getch();
return 0;
}
C# Example... Code:
// Project 1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
int main(void)
{
printf("Hello world!");
getch();
return 0;
}
Unless he was wrong?
__________________
|
|
|
|
|
|
|
#12 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
the first one is C++, the second is in C.
and what you are trying to do it use .net classes in your C++ code which you cant unless you do it in managed C++ that comes with .NET
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
|
|
#15 (permalink) | |
|
Forum Expert
|
Quote:
Well, now this is awkward... I'm searching around for a way to get this to work right now, but can't seem to find any sort of #include typeof thing. Edit: System::Convert::ToInt32 and System.Convert.ToInt32 give the exact same results... heh...
__________________
Last edited by IHaveRegistered; 11-25-2006 at 04:40 PM. |
|
|
|
|
|
|
#16 (permalink) | |
|
Forum Expert
|
Quote:
...you're going to have to pm me the name of this "school" and "course" you took so i can go boof somebody. seriously. that shit's funny. |
|
|
|
|
|
|
#17 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
you might use atoi method. i think prototype was something like:
int atoi (char *) char * c="5"; int myInt=atoi(c); or string c="5"; int myInt=atoi(c.c_str()); you cant use any .NET classes .. edit: Nochte: I dont think any teacher would tell something like that. I think Ihavereg. has misunderstood him.. Probably he was saying one of them C and the orher is C++. (although both have cpp extension)
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Last edited by noobie; 11-25-2006 at 04:50 PM. |
|
|
|
|
|
#19 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
then use atof
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
|
|
#21 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
yea, i think i need some sleep
![]() just cast it.. int a=(int) myDouble;
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
|
|
#23 (permalink) |
|
Forum Expert
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
|
then its already 0 or 0.xx
thats the simplest way of doing it.
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." |
|
|
|
|
|
#24 (permalink) | |
|
Forum Expert
|
Quote:
It should be 7.65, making it 8. speed/strreq 37/35 hitsmax = (int)(((1 / speed) * 3000)); maxdamage = (int)(((strreq + speed + hitsmax) / 20)); hitsmax should be 81.08108108... making it 81 It's below 10 appearently, so an If statement makes it 10. But assuming it WAS 81, then maxdamage should be: 7.65, making it 8. If it was 0, then it should be: 3.6, making it 4. Either way, it shouldn't be 0...
__________________
|
|
|
|
|
|
|
#25 (permalink) |
|
Forum Expert
|
Code:
hitsmax = (int)( ((1 / speed) * 3000) + 0.5 ); Last edited by Sep102; 11-25-2006 at 06:17 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|