108 Posted Topics
Re: Need a lot more detail. You may get a response if you: 1) Post your [B]exact[/B] problem. 2) Show some effort in trying to solve your problem. | |
Re: Well, look through your computer and find the .cpp file with the same name as your project. Once found, the .txt, .dat, etc. file should be within the same location. If it is not, then either you sent the file to a different location, or you did not create a … | |
Well, I am making a tic-tac-toe game, and I need a way to make it so when the person enters their name it adds a ".txt" to the end of their name. For example: What is your name? Robert *ifstream infoout("Robert[COLOR="Red"].txt[/COLOR]");* The .txt highlighted in red is what I need … | |
Re: Well, it's obviously something wrong with your vector. Try posting the whole code, so we can tell you a little more about it. | |
Re: why not do something like this: [code] #include<iostream> #include<time.h> using namespace std; int main() { int random[2]; srand ((unsigned)time(0)); for(int x=0;x<2;x++) { random[x] = (rand() % 8) + 1; cout << random[x] << " "; } cout << endl; } [/code] Edit: Oops, I read it to fast, you want … | |
Hello, I just finished my text-based RPG called Helsmich, however I need a few testers to find bugs/errors and tell me. There are quite a few variables that can be changed in the games such as your name, money, armor, weapon, kills, deaths, strength, speed, defense, accuracy, health, attributes, level, … | |
I really want to add sounds to my programs, but all of the codes I use fail! I am using an empty project in visual c++, if anyone could find a snippet that would work for this, I would be extremely grateful. Thanks! Here is my current code that doesn't … | |
Re: Interesting. You have quite a few unneeded pieces of code, so instead of me telling you all the things you don't need, I will just give you my example to use as a reference. Hope it helps: [code] #include<iostream> using namespace std; int main() { int smallest=100, largest=0, number; do{ … | |
Re: Well, I don't think it is necessarily 'bad', however if someone were to try and use your code as an example, it would be hard for the user to understand what files to include to do what you are doing. (Basically what Narue said). As well, it may slow your … | |
Re: Your code really overwhelmed me at first, but then I got used to it...and I did figure it out. :) Your error is as follows: - You forgot to use #include<string>! (yep, a dumb error, I make them all the time..and I am sure everyone else does too :)) Great … | |
Re: I "shortened" it by more than 40%. [code] #include <iostream> using namespace std; int main() { char flip; int coin, flipnum, flipint, count=0, evod, hityou, hitenemy, youhealth, enemyhealth;; string you, enemy; char flipname[2][25] = {"Heads", "Tails"}; srand(time(0)); //makes rand work cout<<"CHOOSE YOUR MANBEAST: "; //Choose a fighter getline(cin,you); youhealth = … | |
Re: Edit: Nvm, I think I know what you are trying to do, and that wouldn't work.. | |
Re: [code] while (!dataIn.eof()) //Loop until end of text file { examine([COLOR="Red"]in_val, odd_tally, even_tally[/COLOR]); //Call examine function that will determine if integer s odd or even. print(odd_tally, even_tally); //Call function to display results } dataIn.close(); } return 0; } void readFile(ifstream &someFile, int txt_int) { while (someFile >> txt_int); //Read File … | |
Re: You have quite a few problems here: 1) One of your function names is, "avg". One of your variable names within the function name, "avg" is also "avg". VS is unable to discern the difference between the two, and does not accept your variable within the function as an argument. … | |
Re: Please show effort in trying to make the shape, and I will help you. | |
Re: Sampson, this is your fourth thread asking, "How do I do <insert name> in a for loop?" within just 2 days... I am beginning to think that you are doing this just for attention, as I cannot imagine a class that would just randomly assign 'for-loop' problems of such random … | |
Re: [quote] Also when I run the program it never makes it to military time even if I type in M [/quote] [quote] void DisplayTime(int hours, int minutes, int seconds, bool standardTime) { [COLOR="Red"] char ans('S'); [/COLOR] while (ans == 'S') //display standard time cout << "The time is " << … | |
Re: This project interested me, and I decided to try it out for myself. I did succeed in making it, but it is [b]not[/b] the best way to do it. I am 100% sure that there was a simpler way to do this than what I did, so if you want … | |
Re: It simply means that the left value must be a single variable. You cannot have an equation equal to an equation. Try revising it a bit, and see if you can get it to work. | |
Re: I believe I know why, although I am not positive. Anyway, my guess would be that the [10] is only initializing the amount of characters you can have in the word. Therefore, in order to have it as an array you would need: [code]char title[10][25][/code] This works for me anyway.. … | |
Re: Depends on your debugger. I use Visual C++, which I think has one of the best debuggers, as you can right click on the error, and select "go to location". This will automatically position your cursor on the line of your problem. Since I do not know what your debugger … | |
Re: You have to send the variable back to the main function, and implement it into the second function. You can do this using the ampersand character, '&'. IE [code] function(double & value) { double value = 3; } function2(double & value) { cout << value; } main() { function(value); function2(value); … | |
Re: Please don't spam...as well, I assume that you wanted the last pattern to start with 22, not 18, correct? If so, here is the code. This does not sound like a graded assignment to me, because of the simplicity...so here is the original source code: [code] #include<iostream> using namespace std; … | |
Re: Like this? [code] #include <iostream> using namespace std; int main() { int dimension, number=0; cout << "Please enter a number, so I may calculate the size of your triangle: "; cin >> dimension; for(int x=0;x<=dimension;x++) { for(int x=0;x<number;x++) cout << "*"; cout << endl; number++; } cout << endl; } … | |
Re: Your functions are wrong. They do not call+return variables like they should be. Therefore, your going to have 'undeclared identifiers'. Edit: Actually, I am not this advanced in functions yet, so I may have been wrong..but that would be my guess. Sorry I could only give you a guess :/ | |
Re: Works fine for me. It says 0 exchanges were made by bubble sort, and 1 exchanges was made by selection sort. Also, what's this? " cout << "\n" << exchanges ". It is better practice to use endl. | |
Re: Formula is correct. It must be something wrong with your function. Post your whole code. | |
Re: So, your wondering if you can input characters that are not integers? Sure you can. You can use char, getline, or string. I would suggest char if you are just starting to learn. To allow the user to enter in more than one letter simply add an array to the … | |
Re: You need to use srand, with integrated time, so the random integer will change(seed). Example: [code] srand ((unsigned)time(0)); random3 = (rand() % 4) + 1; [/code] Edit: Also include the header: #include<time.h> if you do not already have it. Also, if you don't mind, please send me the source code … | |
Hello, I am trying to make an rpg, and I am having troubles with functions. I am currently working on the 'potion' aspect of my rpg, which I have highlighted in red. My question is this: Is it possible to make the function return money, potion number, potion size, etc? … | |
If so, how do I do it? I need to use it for a project. | |
Re: There are many people doing c++, because c++ is basically a starting ground for coders (at least it was for me). I do not believe that python will 'beat out' C++, even if python is indeed better. Take the HTML v. PHP example. PHP is a much better coding language, … | |
I, the great Restrictment has come to enact great deeds upon this glorious community. If thou shall need a program simply ask and I shall look at thy problem and decide it it is worthy of thy great code. But yeah..it's just me Restrictment. I am new to c++, and … | |
Re: Please insert a double '=' to make it work. IE turn==1 | |
Re: Just a few logic errors. First off: the 'produce' variable is not used, so you can delete it. second: the formula for hourly workers who worked over 40 hours should be: [code]weeklypay=((hours-40)*wage)*1.5 + 40*wage;[/code] BTW, what is the name of your school that you are learning this in? Everything else … | |
Re: Before we 'should' help you, you should post some code before hand, so we can see that you put effort into your assignment. Kontained gave you a good start btw. | |
Re: [code] #include <iostream> using namespace std; int main() { int storage[15]; // Array to store up to 15 integers. int x=0, p=0; // Variable x, which becomes 0 in the for loop. int number; // This will be the number the user enters. // Do while loop repeats until I … | |
Re: Looks like someone else is in your class as well. Please visit this thread that was also made today: [url]http://www.daniweb.com/forums/thread234774.html[/url] | |
Hey, I am just learning functions. I was wondering if you could tell me why this piece of code is not implementing the 'values' function. [code] #include <iostream> #include <windows.h> #include <string> #include <iomanip> void values(float value1[11]); using namespace std; float value1[11], value2[11]; int main() { cout << setiosflags(ios::fixed) << … | |
Just testing out arrays on this one. MY project is to create a thermometer that converts Celsius to Fahrenheit or vice-versa. [code] #include <iostream> #include <windows.h> #include <string> #include <iomanip> using namespace std; int main() { cout << setiosflags(ios::fixed) << setprecision(2) << ios::showpoint; float value1[11], value2[11]; char gauge1, gauge2, gauge; … | |
The question is in the title. I am trying to make an image that includes this character... *typo in title. It should say 'do', not 'to'.* | |
Hello all, I was soooo close to nearly being done with my game..however when I added the final 'armory' loop I got an error! I took the loop out of the program, and ran it by itself, and it worked fine...yet when it is in the program it is wrong? … | |
Hello. I really need help with adding graphics. I have skimmed through multiple tutorials, but all of them have been wicked long, and I honestly don't know how to execute them properly. So I was wondering if any of you had a [b]code snippet[/b] that would allow me to add … | |
Re: Maybe this will work: [code] #include <iostream> //used to seed rand #include <time.h> using namespace std; int main() { int num1 = 4, num2 = 5, answer, random; //random generator srand ((unsigned)time(0)); random = rand() % 4; //do-while to allow the user to try again. do{ cout << "How much … | |
Re: Nvm, just realized I was wrong... Edit: I believe the answer to this problem is within Clinton's post. | |
Re: [code] #include<iostream> #include<iomanip> using namespace std; double winner(double subAmount1, double subAmount2, double subAmount3, double subAmount4); //prototype int main() { //declare variables double saleDept1 = 0.0; double saleDept2 = 0.0; double saleDept3 = 0.0; double saleDept4 = 0.0; double finalwinner = 0.0; //get input while(cin) { cout << "Please enter Division … | |
Re: "Help with my programming assignment" ~ No *Please read the rules first. You must demonstrate some sort of effort before we should help you..* Why? Because it is not only cheating your class, it is cheating yourself. If you don't learn how to problem solve..you never will. It really isn't … | |
Re: Just add this to your coding before your variables: [code] cout.precision(3);[/code] | |
Re: Hello Peter, I believe you are simply missing a header file. |
The End.