- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 20
- Posts with Upvotes
- 18
- Upvoting Members
- 13
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
78 Posted Topics
Re: You're doing the calculations before you're getting the number, and since num will be 0 at that point, tens digit and ones digit will always equal zero, no matter what. You need to take in your number THEN do the calculations for tens digit and ones digit. | |
Re: You may want to start with a loop, to take in the digits. Make sure you have a way to ensure that, when added, if a digit exceeds 10, it gets added to the higher digit. Also, remember that arrays begin with [0] and not [1], when you're programming the … | |
![]() | Re: Your array is not two-dimensional. I also suggest using a variable for input as opposed to just defining every possible outcome. You're setting yourself for one tedious and hard to follow jumble of code. An example: [code] unsigned short x,y; cin >> x >> y; myArray[x][y]= 'X' [/code] This takes … |
Re: I smell homework. Read up in your reference book on implementation of pointers. | |
Re: [QUOTE=jonspeidel;1688769] [CODE]#include<iostream> #include<windows.h> #include<conio.h> #include<strings.h> using namespace std; int main(); void repeat(); void worked(); string s1; string s2; string s3; int main() { repeat(); } void repeat() { string s3="n"; cout << "Would you like to perform another operation?\n"; cin >> s3; if((s3=="Y" || "y")) { worked(); } if((s3=="N" || … | |
Re: [code]if (conversion !=1|| conversion !=2|| conversion !=3|| conversion !=4|| conversion !=5|| conversion !=6)[/code] Can be changed to [code]else[/code] Since the above is implied through the preceding code. Also be careful with your brackets. Line 73 is the end of your do loop and line 76 is the end of int … | |
Re: How can your application send you anything without some form of internet activity? | |
Re: [QUOTE=jackmaverick1;1689724]I think there's a char code that you can use. (like /20?)[/QUOTE] Blank space IS a char. [code] #include <iostream> using std::cout; int main() { char c = ' '; cout <<"Space" << c << "is" <<c <<"a"<<c<<"Character."; cout <<"\nAscii code = " << int(c); return 0; } [/code] Note … | |
Re: [code]Person::Person(string first = "", string second = "")[/code] Out of curiosity, what are you tying to accomplish with your parameters? | |
Re: Just open an output stream and save them to a text file, you're already halfway there. | |
Re: 1. You're not using a char variable, you're using an integer variable. Integers are strictly numerical. 2. Character variables can only hold 1 character. This is due to size limitation of the variable. You will need an array characters to accept input with more than one character. If this sounds … | |
Re: You're asking for input of a character but your variable is an integer, which can only be numerical. The problem your seeing is common to mis-matched variable types. A for loop is also the incorrect type of loop for this particular function. The loop outlined above would serve your purpose … | |
Re: You have your array declare globally, I'd change that. Also, try declaring the range of the array inside your function. I'd imagine by the nature of multidimensional arrays your compiler will want that specified. Example: [code]myfunc(int array[0][5]) //change the '0' to '5'.[/code] | |
Re: [QUOTE=shizu;1494701]Hi luce.. I try your code already.. once compile I get error message like below show.. ****************************************************************** error C2065: 'Image' : undeclared identifier error C2146: syntax error : missing ';' before identifier 'image' error C2065: 'image' : undeclared identifier error C2065: 'GetEncoderClsid' : undeclared identifier error C2228: left of '.Save' … | |
Re: [url=http://advancedcppwithexamples.blogspot.com/2009/08/measuring-elapsed-time-in-c-using_21.html]QueryPerformanceCounter[/url] 20 pixel per second = 1ms x 50 per pixel. Perform the check via subtraction and if the time difference exceeds 50, move one pixel. Of course, you'll then need to reset the "clock" so to speak. Alternatively, you could just grab the time via Clock(), that measures the … | |
Re: You're skipping your if loops: [code] if (gamechoices == "Attack" || gamechoices == "fight" || gamechoices == "kill");[/code] The semicolon ";" at the end terminates the if statement. You need to place anything that will be executed within your if loops within brackets "{ }". It's a common mistake since … | |
Re: 1.Make sure everything is kept as a character; use some denotation as terminator so you can have multi-digit numbers without much difficulty. 2.Convert these chars to their ASCII equivalent integer. If the ASCII value of the char is between 0-9, give it precedence over any non-integer character. A simple boolean … | |
![]() | Re: Why the use of strings? Boolean statements would work just as well(better even): [code] bool seat[200]; [/code] And then... [code] if (seat[input] == 1) cout << "Seat Number" << input << "is reserved. Please choose another."; else seat[input] = 1 [/code] And there you go. Your 500 hundred line case … |
Re: [QUOTE=Moschops;1486526]Your divides function takes two int objects as parameters, and returns an int. Accordingly, you must call it like this: [CODE]returnedInt = divides (someInt, someOtherInt);[/CODE] where [B]returnedInt[/B], [B]someInt[/B] and [B]someOtherInt[/B] are all of type [B]int[/B].[/QUOTE] Or, he could use an if statement to check the returned value like so: [code] … | |
Re: Why use a queue at all? The queue is only gonna return the same thing as your string in the first place. Remember the nature of a stack. A stack is somewhat unfair and believes that the last person to come should be the first to go. Think of a … | |
Re: [QUOTE=Fbody;1484874]So are you saying that you can generate closed-source code, and use a license of your choosing for it, so long as you have an appropriate notice concerning, and provide access to, the MySQL License and Source in compliance with the GPL?[/QUOTE] Read more about the GPL [url=http://www.gnu.org/philosophy/selling.html]here[/url]. | |
Re: Just to clarify, the prototype is what tells the compiler that the function exists, so if another function calls that function before it is actually defined, the compiler knows it exists and doesn't need to throw an error at you. A class declaration (as you've shown), is the same thing. … | |
Re: [QUOTE=schrope;1481422]that is what i thought but it is not working-- i rewrote the last line of code digit_two+=7%10; //add digit_two to 7 and mod 10 digit_three+=7%10; //add digit_three to 7 and mod 10 digit_four+=7%10; //add digit_four to 7 and mod 10 cout <<"Encrypted digits:" << digit_three digit_four digit_one digit_ two … | |
Re: [QUOTE=FriXionX;1478480]Gah, so confusing. I'm gonna learn a bit more, then come back to this, because i dont really understand at the moment. Thanks for the help anyway, ill refer back to this later.[/QUOTE] You should probably find a textbook or some sort and learn from that. If you follow it … | |
Re: You're not looping because s2 doesn't equal anything. Don't use goto, you have the right idea with a loop, you just need to fix your execution. Either: 1. Ask for the input of s2 before ending your loop. 2. Check s1 for a specific input and if it equals that … | |
Re: Hint: You can check the validity of the board by the sum of all the numbers within a given column or row. | |
Re: To see every available character, compile and run this code, if you can make the "cent" symbol in a char or string, it'll be there: [code] #include <iostream> #include <iomanip> using namespace std; int main() { char c; for (int x = 0; x <= 255; x++ ) { c … | |
Re: Your if statements aren't doing anything to begin with. You may want to carefully reexamine if statement implementation. | |
Re: We'll need to see your code to know what's wrong with it. | |
Re: Well, this isn't C++. Also, I don't fully understand the question. You simply specify that Column before you perform the action. There's not much else to it. | |
Re: Well, c++ will be just as complicated as Java and I believe Adobe Air will require you to use Java anyways, | |
Re: This is an error you receive when your compiler can't find the entry point to your code. Your main function cannot be inside a class. How will you access it inside a class? What will call it? You need your main function to be immediately accessible so your program can … | |
Re: What specifically do you mean by "click some button"? | |
Re: You've followed the flow chart well, though you have a typo in your bProd function. Hint: There's a difference between unary and binary operators. Hint2: Is everything in your code being put to use? | |
Re: Please use the CODE tags when posting code, it makes it much easier to read. Also, please post your whole code. | |
Re: Your positioning is the reason. [code] do { cout << "do you want to play again? (y/n)" << endl; cin >> ans; if (ans == 'n') { cout << "Thank you for playing...... press <enter> key to exit"<< endl; cin.get(); found = true; } if ( ans == 'y') { … | |
Re: Most likely you're exceeding the limitation of the variable, so at some point, it's counting over to 0, and then multiplies from 0 there onward. Not much can be done about that, except perhaps storing the number inside a container or something of the like. You're not going to find … | |
Re: Show us what you have so far. | |
Re: Yes, any integer-like variable type: [code] short isValid = 1; [/code] 0 is the same as false, and any other value is equal to true. One such instance in which this would be a useful tactic is error handling, where false would mean no error occurred, and any true statement … | |
Re: setprecision affects the output stream, not the variable, therefore, it will continue to display the precision until you change it. Example: [code] #include <iostream> #include <iomanip> using std::cout; using std::setprecision; int main() { float x = 5.12384; cout << "Variable = " << x << "\n"; cout << "Precision 2 … | |
Re: Short answer is no. Your example for "4" could be achieved with a simple if statement. I can't think of a single situation where this couldn't be replaced with something else. If your planning on using 1 in a lot of formulas but may need/want to change them all later … | |
Re: [QUOTE=TheLittleEngine;1473494] so far all I've understood is passing by reference creates a copy of the item[/QUOTE] Passing by reference does NOT create a copy of the item, that's the whole point of using it. It manipulates the original(by passing the memory address) so when your function ends any change you … | |
Re: Ubuntu should come prepacked with g++. If not: [code=bash] sudo apt-get install build-essential[/code] For dependencies, then... [code=bash] sudo apt-get install g++ [/code] It's a command-line compiler, meaning you'll have to operate it from the command prompt. If you don't like that idea, you could get code::blocks, and IDE, from the … | |
Re: How about you start by telling us what exactly you're having a problem with? Do you need help figuring out the logic? | |
Re: I doubt you can even get it to compile, since you haven't included the proper headers for "cout" and "cin" Also, xact_type will always be equal to itself, your if statement is not doing anything. You had the right idea the first time, just the wrong syntax. You need to … | |
Re: You need to put a length to compare. The compiler tells you the exact problem, not enough arguments, you need a size_t (or, rather, in the case of strings, string.size, usually) as a third parameter. | |
Re: One thing sticks out, it's not a huge deal, but what if your user enters a word that starts with "q"? Since ch is equal to the first letter in the string it would quit on them even if they didn't actually want to. Also, you're only checking for lower … | |
Re: You shouldn't need to dereference when passing by reference, only when it's a pointer. It seems peculiar but it could be a quirk of VC, especially if it compiles fine under other compilers. Does it run fine after you compile it in g++? | |
Re: When you copy the vectors of pointers you copy the [b]locations[/b] they hold, meaning, you copy the address of the vector you're copying. The pointers then no longer have access to their previous values and if you initialized those values with the pointers they are now lost and cannot be … | |
Re: [QUOTE=alex55;1469981]can i output to the same file twice without having it overwrite using my outFile stream?[/QUOTE] Yes. It depends on how you open the output file. You need to append it instead of truncate it. [icode] ofstream output(filename,[b]ios::app[/b]); //The bolded sets to append instead of truncate. [/icode] |
The End.