|
M. Atul wrote: i want to get ID of controls used in CommonDlg box used.
Those are in dlgs.h .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
is it right to say that preprocessor directives is
#include<iostream.h>
and
preprocessor is a character
#
|
|
|
|
|
The preprocessor is a program that takes a source file and does things to it before the compiler sees the file. Directives are instructions to the preprocessor telling it what to do. More info here: clickety[^]
|
|
|
|
|
Hi
Does anyone know how to prevent self assignment of object.
E.g If I have a class A,
A a;
a = a; // how to prevent this
|
|
|
|
|
|
ragavan wrote: a = a; // how to prevent this
What do you mean "prevent"? You want a compiler error?
If you just don't want the assignment to happen you can create an assignment operator and check if the right hand side value s address == this and do not perform the assignment.
led mike
|
|
|
|
|
You probably also want to prevent the copy constructor. I guess your question is regarding manual memory management, classes that handle memory/resources might need a decent copy constructor and an assignment operator (or alternatively a prevention of shallow copy).
For details please see boost::noncopyable and the Law of the Big Two.
In my class designs I sometimes take the easy way and just use 'noncopy' to prevent the shallow copy (which also means users can't make a copy of the objects, which really is fine for some classes). But sometimes you actually want this feature and then I implement both copy contructor and assignment operator (with a check for accidental self assignment).
Hope it helps,
M
|
|
|
|
|
Hi all
I posted a message days before when I got an error message " program too big to fit in memory " while executing a binary . When I ran depends.exe on the problematic exe to my surprise I found that "at least one of the files are not Win32" ! . A quick question to my collegue who asked me to run this exe confirmed that he had sent me an exe intended for linux environment !
My question is : why did not I get a direct message like "non windows exe" or something like that ?
Why this "too big to fit in memory" message which misled me to beleive I might have some RAM issue/page file issue etc ...?
redindian
|
|
|
|
|
Well, if the exe is win32, it will run, and try to use the other files that were provided with it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Hi christian
My question is , Why not MS provide us with a valid message instead of misleading one that points to a memory issue ?
redindian
|
|
|
|
|
Your question makes no sense. MS is not misleading you at all. They are running the exe you have provided, it's trying to read the files that came with it, and failing to do so. If I put datsun parts in my ferrarri, is it the ferrarri's fault if it doesn't know how to use them ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
dharani wrote: My question is : why did not I get a direct message like "non windows exe" or something like that ?
Because windows would expect this module to be in the PE format. I guess that somewhere in the PE header there would be a field indicating the amount of memory needed to load and run the module. The file you have probably has some huge number at this offset that windows is interpreting as the memory size required.
|
|
|
|
|
i need to write these commands only and run:
#include<stdio.h>
main()
{
printf("Hello\n");
}
A step by step tutorial on Visual Studio 2005 please...
Dont need other libraries such stdafx.h and other code such :
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Just want to run the command above without any errors just i did in my lesson ,but in Visual Studio 6
Thanks
|
|
|
|
|
Do what I said to do before - go to File/New/Project. Select Visual C++/Win32.
Now create a Win32 Project. Enter a name and click OK. Now click on 'Application Settings' and choose 'console application' Deselect precompiled header and choose 'empty project'
Now right click on the project name in the solution explorer and choose add/new item. Click on 'code' and C++ file. Type in main.c, and click OK. Put your code in, and VC++ will know it's a C project, and it iwll compile and run just fine.
The one thing is, the app will not pause for you to see the output, you need to add a line to read text, or set a break point, in order for the window to not open and close again right away.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
That's what i mean a tutorial!
But i am stupid...
I doubled clicked in the end of the code and Click On Insert a breakpoint. Nothing apears,like a console,when i click compile!
what should i do??
Do you know the code for something like this ??
*
**
***
****
Until ten asterisks ?
Thanks a lot man! you are great!
|
|
|
|
|
WakenDJ wrote: Click On Insert a breakpoint. Nothing apears,like a console,when i click compile!
Inserting a break point will just put a dot there, it won't do anythng until you run it, and only then if it's within the code that gets run.
WakenDJ wrote: Do you know the code for something like this ??
*
**
***
****
Until ten asterisks ?
Yes, but that would be a homework question. What do you think the answer would be ? I'd do it using a nested loop.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I finally ran that damn Hello World! i am proud ! lol
Yep this is an exercise for today in my class... Can you tell me the way if it is ok please?
is there any specific place i should put that breakpoint,cause after the console apears ,it stucks and i have to close is through the task manager
|
|
|
|
|
You'd do better to add a line that reads input from the console. The point of a breakpoint, is that the program stops and you can examine variables and start it again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
I added a scanf before printf and added a breakpoint a step back of } .. it works great but why the console stucks there and no responding?do you think it is a Visual Studio problem ?
|
|
|
|
|
No, the console gets stuck because that is what a breakpoint is for. You need to add a line AFTER the printf, if you want the program to stop and let you see the printf output.
Regarding your assignment, what you need to do is have two loops, that's called a nested loop. One loop controls the number of lines you print, the other loop prints the number of #s in the line. Have you covered for loops in class ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
A half an hour about FOR and a statement about do while,nothing more.
I think you didnt get me.My english are not so good.
I added a breakpoint after printf just like this:
#include<stdio.h>
main()
{
int a;
scanf("%d",&a);
printf("Hello\n");
BREAKPOINT
}
I mean not responding.I have to press CTRL + ALT + DEL to close it from there.
That this happens with the breakpoint embedded.Without it it works great but i cannot see the printf.With it i can but it crushes!i finally found the word i need!
Can you please tell me the code about that program with the asterisks? with do...while at least.It is too difficult to find it out.
|
|
|
|
|
If you add a break point, the program will stop. If it crashes, then it's broken. If you did what I suggested, then you wouldn't need a breakpoint.
main()
{
int a;
printf("Hello\n");
scanf("%d",&a);
}
This will stop and wait for you to enter a number.
WakenDJ wrote: Can you please tell me the code about that program with the asterisks? with do...while at least.It is too difficult to find it out.
No - the point of your course is that you learn both C, and how to do a little research. I've told you all you should need to know. The next step is to ask yourself, what does 'do while' do ? How can it be used to create this output you're after ? What data do you need to generate that output ? Think about it in small steps. If you still can't work it out, you need to speak to your teacher for some help, so she knows your level of ability and the difficulty you're having and can tailor her efforts to helping you understand these basic concepts.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Your are right... thanks for your help!
so far i found this:
#include<stdio.h>
main()
{
int num;
for(num=0;num<=10;num++)
printf("*\n");
}
I know how to show the first numbers like 1,3,5,7,and i think it works the same way but nothing so far!
|
|
|
|
|
The output of this code will be:
*
*
*
*
*
*
so on... till ten times
Edit: it repeats itself 11 times (I didn't realize about the i <= 10)
-- modified at 3:13 Monday 14th May, 2007
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
WakenDJ wrote: int num;
for(num=0;num<=10;num++)
printf("*\n");
this is a good start. Now think, how many times does this loop fire ? The answer is 11. You want to do this:
for(num=1;num<11;num++)
to count from 1 to 10.
Now ask yourself, you want to print out 10 lines, right ? The first line has 1 * in it, the second has 2, and so on. So, how will you know on each line, how many stars to print out ? And, can you write a loop to print those stars out ? Then you just need after your loop to print a \n to go to the next line. Actually, I thought it was \r\n.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|