|
|
I just finished a simple program, but it keeps saying that I have a error. The error says that "end of program is found before left brace" line 37. What does that mean, here's my code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
double sales = 0.0;
double totRegSales = 0.0;
int region;
int outlet;
while (region <= 5)
{
cout << "region" << region << endl;
outlet = 1;
totRegSales = 0.0;
do
{
cout << "Enter sales for outlet" << outlet << "enter 0 for next region):";
cin >> sales;
totRegSales += sales;
outlet++;
}
while (sales != 0.0);
cout << "region " << region << "sales total:" << totRegSales << endl << endl;
region++;
}
cout << "End of program" << endl;
|
|
|
|
|
|
where am i missing as "}"
|
|
|
|
|
|
at what spot should I place the "}".
|
|
|
|
|
at the end of the program.
all functions MUST end with a }. the code you posted above does not end with a }.
put a } at the end of the code, after your last "cout << .."
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
st039 wrote:
int main()
{
Place the cursor just to the left of this left brace. Press Ctrl+] on the keyboard. The beep that you should hear indicates that no matching brace could be found.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I am working on a visual c++ project which has been getting lots of C4244 warnings (conversion from 'double' to 'int', possible loss of data), but has been working ok (as expected).
I made an effort to eliminate the warnings at first by using a preprocessor definition for round(x) (assuming that rounding was the intended operation in the first place) and then trunc(x) (#define trunc(x) (int)(x)) ), after finding out that rounding was not the intented operation after all.
Now, reading the related help files, I was under the assumption that the default compiler behavior when assigning a double to an int, is to truncate the double and assign only the integer part, thus, my trunc(x) preprocessor definition should work just the same.
Apparently, it doesn't.
Apparently, casting a double to int to get rid of the warning, does not truncate the double, or I am missing something here...
Does anyone have a clue about what's going on here?
Thanks in advance.
|
|
|
|
|
AsGoodAsItGets wrote:
Apparently, casting a double to int to get rid of the warning, does not truncate the double, or I am missing something here
correct. casting double to int makes a copy of the double, truncates it, and assigns that to an int.
if you want to truncate a double in-place, you can do something like:
double foo;
foo = 1.234;
foo = (double)(int)foo;
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
I would use floor(), as it might be less confusing than casting twice.
--
Marcus Kwok
|
|
|
|
|
Sorry, I'm afraid I have not made myself quite clear about the problem.
I do not want to truncate the double and assign it back to a double.
I have a program with lots of warnings about double to int assignments, and I want to gracefully get rid of these warnings, without modifying the default program behavior. As I have explained, my efforts so far (with casting and using round(x)) have been fruitless.
|
|
|
|
|
What about something like:
double d;<br />
int i;<br />
<br />
<br />
<br />
i = static_cast<int>(d);
--
Marcus Kwok
|
|
|
|
|
Hi,
I have a derived CFormView called CMyView. In this class there are DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE Macros.
In my CMainFrame i have a Message Handler to catch a menu click.
void CMainFrame::OnFileMyview()
{
if ( m_pClass != NULL)
{
m_pClass = RUNTIME_CLASS(CMyView);
m_pMyView = (CMyView*)m_pClass->CreateObject("CMyView");
}
}
How do i get my CMyView to display in my window.
Thanks
Gary
|
|
|
|
|
|
Hi,
I would like to draw a transparent ellipse with the border RED
For that I have set the CPen and I have done : pdc->SelectObject(pen)
But with the brush ( CBrush ) in order to put : pdc->SelectObject(brush) , I don't wanna set any color...only transparent...cause this ellipse is going to be drawn on an existing draw that I want to keep
Help please!!!
Thanks
|
|
|
|
|
Try:
pdc->SelectStockObject( NULL_BRUSH );
Larry J. Siddens
|
|
|
|
|
My employer wants me to take a Brainbench Visual C++ test . The fact is that I have been coding for the most part using mFC. Just to see where I was placed , i took the test and scored a dismal 2.71 . The bar set by my employer is 4.0 . I would like to get information on preparation material for the test .
Thanks
|
|
|
|
|
I took that same test and scored about the same as you. I apparently don't know what I am doing, or the test is not a good indicator of what I do know.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Generally in a work environment , one gets to work on a limited area and the focus is on using the easiest framework to get the job done asap .The test covers all the areas under Visual C++ from device Contexts , OLE ,Active X , COM and general Win 32 stuff .
Why would my boss care if I used MFC or Win32 .
Employers should realize this .
Engineering is the effort !
|
|
|
|
|
act_x wrote:
Generally in a work environment , one gets to work on a limited area and the focus is on using the easiest framework to get the job done asap .The test covers all the areas under Visual C++ from device Contexts , OLE ,Active X , COM and general Win 32 stuff .
I knew all of that going into it. I just took the test for fun and because it was free.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
did you get to use CP (and/or google) like you would obviouslly do in _real_ life?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
I'm starting to work with stacks and binary search trees, I wanted to know with regard to stacks, where are new nodes added and existing nodes removed?
|
|
|
|
|
Think of a stack as that thing you used in the high school cafeteria that held the trays. When you needed a tray, you took the one from the top. When a tray was put back on, it was added to the top. Google for FIFO.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Wouldn't FIFO (first in, first out) be a queue? I think you meant to say LIFO (last in, first out) since the last thing you "push" onto the stack will be the first thing that you "pop" off of the stack.
--
Marcus Kwok
|
|
|
|