Are you using Winforms or Win32? If Winforms, search on "GDI+ tiling an image" (some of the examples are for VB, but the syntax should be easy to translate to C++/CLI)
Are you trying to display it or do you need to save a copy out like that?
Are you using Winforms or Win32? If Winforms, search on "GDI+ tiling an image" (some of the examples are for VB, but the syntax should be easy to translate to C++/CLI)
Are you trying to display it or do you need to save a copy out like that?
I don't quite understand how it "worked wonders" then. Unless you've got your function definitions out ahead of main(), there should always be prototypes. Anyway, thanks for clarifying it.
make a variable called total, initialize it to zero
for loop (i: from 0 to NUM_SCORES)
total+=score[i]
Then divide total by NUM_SCORES
You can create a total variable for each of A, B, and C, or you can recycle it by setting it to zero in between loops.
You're just jealous that the "TV timeout" was invented in the States. ;)
In your loops where you are inputting the values, keep a running sum of the scores. Then outside of the loop divide by NUM_SCORES.
I meant more for you to show us what you tried with the passing by reference.
Please post your current code with the changes you've made.
if(i=2)
Does that statement look correct to you? You need to be testing for equality (==) and not assigning (=). I don't think that's the entire issue, but start there.
Check out line 8 of your original posting, your prototype says that it takes 3 arguments. Something must be changed so the number of parameters matches up in your prototype (line 8), your definition(line 63), and your function call (line 22).
Check out Emergent http://grey.colorado.edu/emergent/index.php/Main_Page. It's got a bit of a learning curve, but in return for it you get a very powerful tool. I haven't used it recently, so I'm not sure how much help I could be with it.
This one http://www.justnn.com/ is more straightforward.
Test whether letter.length() == 1
and while you're at it, check to make sure it's a valid letter using isalpha() from <cctype> (or your own version).
Can you not change the signature of the function to take a char?
That's what I was thinking, too, but it doesn't make sense in the context. LOL I guess we'll have to wait and see what he says.
It's like all "American" sports, more stop than start.
Pray tell, what is the sport of your nation that puts the "American" sports to shame.
The function "getinput();" is a prototype function..
I've never heard the term used like that. What exactly does it imply?
Also, what could be considered an opinion or design choice, but the do/while loop avoids the potential stack issues with the recursive function.
Look on your start menu and under the Qt folder (or wherever you installed it), there will be a Qt 4.whatever command prompt icon. Starting that will put all of the proper environment variables in place for that session.
There's some specific compilation steps that you'll have to look up (I haven't done it in a while), so grab a good tutorial (like the first edition of C++ GUI Programming with Qt4 available at http://www.qtrac.eu/marksummerfield.html free and legal -- it's getting a little bit outdated but the beginning material in the book should have remained constant over Qt releases).
Fair enough. I was misled by the words "Our C++ forum is the place for Q&A-style discussions related to this popular language"; to my mind, CLI is not C++, but I can see how one could argue it is related to it.
I never said that it was C++ in the purest sense, just that questions about it were welcome here.
Can I ask about ALGOL? :)
You certainly can, but it will probably get moved to the "Legacy and Other Languages" forum and get all of the attention it deserves. ;)
It's C++/CLI (used on the CLR in .NET) and it's certainly welcome here.
gcc 4.6 hasn't been released yet. I checked on http://gcc.gnu.org/gcc-4.6/ and there are no stable builds listed on that page. You'd have to get a nightly release (I don't know where to find those) of the prerelease code. I'm not sure what the status of the mingw (the Windows port of gcc) is for 4.6, but since it's even less likely to be ready, you'd probably have to build the Linux nightly build under MSYS (http://www.mingw.org/wiki/MSYS).
I would get the latest mingw release (v.4.5.2) which is simple enough to set up (there's an installer now for Windows) and use that with Code::Blocks. You won't get all of the experimental keywords from C++0x, but using that website that Moschops posted, you can see how many of them are already available.
Have a look at this http://www.daniweb.com/forums/post155265-18.html. It tells you how to avoid that situation.
In response to jonsca, the Mono project isn't as up to date as the Microsoft implementation of .net for obvious reasons but it does help.
Yes, after I'd written that I'd thought about looking into the extent that it was compatible, but got sidetracked. A very good point.
@OP I didn't realize that the introduction of stuff was staggered like that, so unless you have the 4.6 my suggestion won't work. Apologies.
Consider a smaller example:
1000 0000 //0x80 as a mask
Take the number:
0100 0110 //70 decimal & it with
1000 0000 = 0000 0000, first digit is 0
<shift bit of mask to the right>
0100 0000 & it with
0100 0110 = 0100 0000 => second digit is 1
<shift bit of the mask to the right>
0010 0000 & with the original number
etc.
So, you're using & to test the bits one by one to see if the given number's bits are 1 or not. If they are 1, the and of the bit in the original number with the mask is 1.
The mask allows us to focus on the bits one at a time.
See this: (the first half, particularly the links to their FAQ) http://www.tek-tips.com/viewthread.cfm?qid=1295422&page=9 It sounds like you either need to redistribute the bpl file with it or compile it with different options.
Go into C::B and open up Settings/Compiler and Debugger Settings and select GNU GCC Compiler at the top (assuming you load up C::B on your laptop with the default compiler). Select the Compiler Settings tab, and go down about 9 entries to "Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]." That should allow you to use the new stuff.
Just select a "Win32 console project" to do "regular" C++. The alternative to .NET is using a "Win32 project," where you can use the Win32 API (see http://www.winprog.org/tutorial/ for an excellent intro to the subject). There's a steeper learning curve for the Win32API, but it brings you much closer to the OS.
I would at least take a look at some benchmarks before denouncing it completely, Mike. Intuitively, it feels like it should be slow as molasses, but in practice the JIT compilation can actually make it faster (see http://stackoverflow.com/questions/1500584/performance-difference-between-c-and-c-for-mathematics).
not portable
Not true anymore. Mono Project?
What is it doing/not doing and what do you expect it to do? In the future, it helps to know what area is going awry. It helps us get to the problem much faster.
void main()
Ugh, you had it correct before, what happened?
Remember that atFound > 1
is already true if atFound > 1 and false if it isn't, there's no need to test that. You can either return !(atFound > 1);
or return atFound == 1
to get the result that you want. Yours is not wrong at all, but you're retesting something that doesn't need to be.
Looking at line 47, a getline command returns a reference to an istream object, not a string (don't worry about what the first part means, but just test the string directly with oneAt() after you've read it in).
(as an aside, give http://www.daniweb.com/forums/post155265-18.html a read about why .eof() isn't a good idea)
Again, I'm not an expert, but I think you should have clarified it was a CGI that you wanted to run, not strictly a C program. I think that CGIs had their heyday in the 90s, but have given way to Javascript on the client side interacting with PHP on the server side. This may be a question more for the web development folks. If you think that's the case, hit the "Flag Bad Post" under your name and ask for the thread to be moved to another forum of your choosing.
I unfortunately have to head out, it's been a long night. Keep at it and post your progress and someone else should be able to help you. I think you're starting to get it.
Your original specification says interest will be compounded monthly, so line 39 is incorrect. Look it up online if you're not sure what "compounded monthly" means.
You've lost your outer while loop somewhere.
It doesn't ask for you to put a message that the account will be depleted, just a message at the end telling the user how many months it will take.
I think some of that is probably a few lectures down the road for the OP, though. I agree in that I didn't understand the need to convert to int and then write it out again.
I have given you hint after hint. I'm not going to do this for you. Take more than 2 minutes to fix it and repost what you have.
Our posts crossed. Don't redeclare the variable there anyway, but declaring something /2 is not the proper syntax.
Line 28 and line 35, there's no such value in the file.
Determine what Total is, but don't loop over it. Then, if total is less than zero, loop until the original amount is less than or equal to zero, adding the total to the original amount each month.
Line 44 is coming out of nowhere, you already have Month as a variable (that shouldn't even compile).
Okay, you're getting closer. Take some time with it and check your answers with pencil and paper to make sure your program is doing the right thing.
Hint: you'll need to take in your next line of the data file somewhere within the outer while loop.
Check and see if the account can be depleted (so is the amount we're adding every month, interest - tuition, is less than zero).
If it can, then go ahead and see how many months it will take using the inner while loop.
If it can't be depleted, skip over the while loop and get the next value ins >> originalAmount;
.
For checking if it can be depleted, you would need an if statement, so sorry if my prior comment was misleading (I thought you were asking if you needed an if statement to test the condition of the while loop).
The while loop will work on its own. You'll test a condition like amount > 0 with it, just like you would in an if statement, but you don't actually need one.
so if the total amount is greater than the original one, the account will last forever?
If I give you 10,000 and the amount I'm adding to that $10,000 is positive (so the interest earned exceeds the tuition paid out), how could the account go negative or to zero?
when is the total amount will be depleted at a specific time?
As we're computing the interest, adding it in, and subtracting the tuition, we'll have 10,000, then 9,900 the next month (I'm making up numbers, but you get the idea), then 9,800 the next month after that, eventually you'd find that after 100 months you'd be down to zero.
Check his thread too for answers.Good luck
Or you could let people write their own code.
Learn the rules. Thank you.
Nope. I will not. It's against site policy, and you will definitely not learn anything that way.
Keep at it, you're almost there, but this has to be your effort.
Can you keep your numbers in an array? If not, you're going to have to "get" and keep a count of the number of valid digits (hint, you can use < and > with chars), and then "unget" to go back to convert them to numbers.
double runningTotal; //set equal to first dollar amount
int month=0;
while(originalAmount > 0)
{
//check to see if we can in fact count down to $0.00
//if so, continue on, if not, tell the user and skip down to read in another val
while(runningTotal is more than a cent) //might be hard to hit zero so go for a penny
{
//adjust running total by months interest and subtract expenses
month++;
}
//set runningtotal to next amount
}
You have to add it to the tabPage of the tabControl directly. I hid the PB until I repositioned it to where it belongs. Other than that, what I replied with before should do the trick.
I was saying that if you weren't modifying originalAmount in the loop then the while loop condition would never be met. You are reading it in at the end, so that's fine. However, even when the last datapoint is read in, won't originalAmount still be >=0 causing the loop to continue? Change the condition to require it to be greater than 0 only.
I would have a second while loop inside of the first one that counts down and increments month. Then you can output month, reset it to zero and go through the loop again for the second value. Check the order of your calculations, as you need to wait until you know the final months value before you find the number of years and spare months.
Also, please use code tags when posting your code. Type [code] //code goes here [/code]. A mod was nice enough to put them in your first post.
The first actual command of cashier is a cin on line 84. Your program is waiting for your input. Put any text to output before that.
Okay, well make sure the condition you are testing for changes somewhere in the loop, otherwise it will loop forever. Post the modified code.
I think using "%02x" will do the trick.
malloc sets aside a block of memory, it does nothing to initialize it whatsoever. You get whatever happens to be sitting there. You could possibly use memset to blank the char arrays out (I do not know enough about how it behaves or if there are any side effects/gotchas associated with that). I'd say just put a guard in place to prevent the user from displaying the data before there are data to be displayed if you are concerned about it.
Month has no value in your program, so you end up with whatever junk is in there when it was declared. You declare it, and then you try to use it in calculations but nowhere is it assigned. Your program should be finding the value of month to deplete the account. You'll want to use a loop and have a counter to determine how many times you go through the loop. Write it out in pencil and paper first to clarify the calculations.
Hint, to test if it will never be depleted, see if the interest earned for the month minus the college expenses is positive or negative.
Okay. My sentiment is still the same, though, you can't display what you haven't put in yet... What do you expect will happen when you do that? (maybe I'm missing something here)
well you can, but you wouldn't want to because you'd have to write a lot of complex code that has already been written by other people and packaged into a nice library).
That's an excellent point. I should clarify the issue when I say that, I meant that there's no single function or class specific to the task of image manipulation. Certainly, you can read the file directly as binary, as ravenous is attesting.
Well, if you haven't added any records in, then don't try to display them. You've discovered that when you declare a variable in C, there could be any junk at all in it. You could add something to your code to make sure that there are records before you display them.
Also, why is the menu in that screenshot different than the one in your code?