|
Hi bob16972,
static_cast is an operator in C++, how do you think we can use it in pure C program?
regards,
George
|
|
|
|
|
Considering this is a C++ forum, I assumed you were using .cpp files. If you are truly using .c files then my apologies. I haven't compiled a "pure" C program since 1992 or 1993.
Either way, I don't use static_cast myself so no harm no foul.
|
|
|
|
|
Thanks bob16972,
It is ok.
regards,
George
|
|
|
|
|
If you don't care about 64-bit compatibility warnings, why not turn the 64-bit compatibility check
off in the compiler settings?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your new idea, Mark!
Do you know how to turn 64-bit compatibility back? Which compiler settings (macros) should I look into?
regards,
George
|
|
|
|
|
I'm still not sure if that's why you're getting the warning. I thought you stated you tried
unsigned int instead of int in an earlier post - if that's the case then it's probably a 64-bit
compatibility warning.
If you go to the project properties, the C++/General page should have the "detect 64-bit portability
issues" switch.
There's also #pragma warning for turning on/off warnings for sections of code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your advice, Mark!
regards,
George
|
|
|
|
|
size_t in unsigned but int is signed.
Steve
|
|
|
|
|
Hi Stephen,
If I am converting size_t to unsigned int on 32-bit platform, are there any risks of data lost?
regards,
George
|
|
|
|
|
It depends on how the conversion is done. Why not use size_t directly. If you can't perhaps unsigned int would be a closer match.
Steve
|
|
|
|
|
Good idea Steve,
I will try to change the function signature (parameter type).
regards,
George
|
|
|
|
|
Hi all;
I am (new to c++) trying to write a program which in part of it has a list of objects with a few variables.(pseudo code)
lets say:
class cObj
{
private:
int objNum;
string objName;
}
list<cobj> ListObj;
and we have three objects
obj1 ( onjNum =1 , ObjName = One)
obj2 ( onjNum =2 , ObjName = Two)
obj3 ( onjNum =3 , ObjName = Two)
and i want to search all the objects that have the name "Two".
result should be: &Obj2 and &Obj3 (or pointers)
how can i do it?
thanks a lot;
Beri
|
|
|
|
|
If you store then in a vector, you can write a functor to do the search you are after and use the built in search algorithms.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thanks for you kind help!
i see, vector has a random access to any position.
but if i had to use a list(not only because i wrote a very long code :P)?
isn't there any option to check something like this:
lets say i have a function:
bool mysearch( string _objName)
{
int found = 0;
list::iterator iter;
iter = list.begin();
while(iter!=list.end())
{
if(iter.objName== _objName) //iter.objName is my problem - how to implement
found++ // get the times objName found
}
}
thanks a lot;
Beri
-- modified at 3:12 Saturday 28th July, 2007
|
|
|
|
|
You should overload the == operator and use the find algorithm.
<br />
class cObj<br />
{<br />
int objNum;<br />
string objName;<br />
Below,you can actually have the int type as well that you can check for your "2" directly than passing it from an object. But in case you want to change the search condition sometime later, this doesnt help. Better pass the object and get the member from it.
<br />
bool operator == (const cObjSent)
{ <br />
return ((objNum==cObjSent.objNum));<br />
}<br />
}<br />
<br />
void main()<br />
{<br />
list <cObj> cObjObject;<br />
list <cObj> ::iterator cObj_iter;<br />
<br />
cObj_iter = find(cObjObject.begin(), cObjObject.end(), YOUR_COBJ_SEARCHOBJECT_HERE [Like for eg:your obj2]
);<br />
<br />
}<br />
<br />
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
thanks a lot Marc!
May The Force Be With You...
|
|
|
|
|
Hi all i want to make progress bar inside list control(report style). I have found various articles regarding this but they don't fulfil my requirements.
i have made a sdi application and that sdi window is divided with a vertical splitter controls in two parts.Each veiw is derived from CFormVeiw and have a list control in it.I want to make progress bar in my list control and that progress bar should start when i click a button on toolbar.
How to do this.....
Thanks in advance
|
|
|
|
|
There are very good examples regarding this on codeproject i dont remember exact names but try something XListControl you will get it.
|
|
|
|
|
|
Hi,
I want to write a program that when I input integer then the output will have commas if it has more than three digits. For example,
-2007 and 2000000 would be printed as -2,007 and 2,000,000 respectively..
# include <iostream>
# include <iomanip>
using namespace std;
int main ()
{
double digit;
cout <<" print it with comma "<< endl;
cin >> digit;
cout <<setiosflags(ios::fixed| ios::showpoint)<< setprecision(3) <<endl;
cout <<digit <<endl;
return 0;
}
dalmar mahamoud
|
|
|
|
|
This really sounds like a homework problem. It is not that difficult to do.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all. Is it possible to have a program that executes under a different name under Windows? For example, program.exe executes under newprogramname.exe? Only reason why i asked is because i've always wandered how installation programs do it. Thanx in advance!
|
|
|
|
|
I don't think it's possible. If it was, it would be a heck of a security vulnerability - unless the full path was placed somewhere, it would screw up every piece of anti-virus software in the world.
Install programs execute under the same name, as far as I know. It's just that they sometimes create temporary apps and run them as children.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
I don't think it is possible, and could be suspicious...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Yes!
I do not know what ‘Ninja-the-Nerd’ was talking about, but you can change the name all you want. What that has to do with installation I have no clue – so obviously I have no idea what you are talking about.
If you do not believe me – pick a program and rename it through the explorer and then run it.
The only problem that might occur is if that program was specified as the one used to handle a particular file format. If you change its name – then the system will not know what program to use (now), unless you tell it what the new name is.
Well actually – depending on the program – there could be other problems (rarely) if other programs depend on that one (a.k.a. file type handling). But let’s not go there or we will all end up with a head ache .
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|