- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 11
- Posts with Upvotes
- 10
- Upvoting Members
- 8
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Re: You just want to know how to print a table? I did it using three for loops, kinda like this: [CODE] cout<<"\n"; for(int x=0 ; x<=3; x++){//prints rows of 4 incremented rates cout<<"\trate"; //print one row, then increment the rate }//end for cout<<endl; for(int y = 1; y<=12; y++){//makes 12 … | |
Re: [QUOTE=WaltP;1159755]here we do not not give programs to people,[/QUOTE] Ah, so you [I]do [/I]give programs to people? //just kidding...double negative there, lol | |
Re: Correct me if I am wrong, but it looks to me like what you would like to do is something like this. The inputs are labeled A, B, C, D, and E, respectively. So your first input is the rank of where A is, out of the total amount. So … | |
Is it the boost library? Regex in particular? I have searched and searched, but this is all I could come up with. If this is the correct library, then how do I get it to work in Dev-C++? I managed to add all the boost .h files to my Dev-C++ … | |
Re: The error I get is 'address of while(AreThereMore) will always evaluate to true.' You need the ()'s when calling the function. Also I see a couple of things in your AreThereMore() function: If answer is not true, you need to set it to false. And when you compare you need … | |
Re: It seems to work fine for me, too, though it took me a minute to figure out what the program does. The first number input is the size, right? So if you input 4,3,2,1,0 it will say that the size is 4 and the elements are {3} 2} 1} 0} … | |
Re: My compiler would not let me use sleep (with a small 's'). And...I always use larger numbers. I don't think your delay is very long. If you want a half-second delay: [CODE]Sleep(500);[/CODE] You don't need the tab, if you want the stick to show up in the same spot each … | |
Re: i++; j--; If j==5 and i==0 and we increment i at the same time as we decrement j... after the 1st iteration: i = 1 j = 4 2nd iteration: i = 2 j = 3 3rd iteration: i = 3 j = 2 And your loop doesn't stop until … | |
Re: EOF means end of file. You can check for it like this: [CODE]while(!infile.eof())[/CODE] It looks to me like you have closed your file and then tried to read from it. [CODE]infile.close(); //Force closes the file while (infile) { if([/CODE] | |
Re: I would use [iCODE]string grade;[/iCODE] instead of [iCODE]char grade;[/iCODE], so that you can have the - or + with it. A char represents [I]one [/I]character. Also, why don't you use [iCODE]int main() [/iCODE]instead of [iCODE]void main()[/iCODE] ? And you probably want [iCODE] #include<iostream>[/iCODE] instead of [iCODE]#include<iostream.h>[/iCODE]. | |
My assignment this week deals with using a struct. I think I can do that part. What I'm having trouble with is reading the file into each variable. The first item in the file is text with spaces. The next items are numeric and need to go into other variables, … | |
Re: It is because each line executes in order. The order you have here is to check if f == 5 first, and if so then cout<< your message. If f!=5 though, it will check to see if f==5 once, then go into the loop. There is no code to take … | |
Re: Well, just look where you put the brackets and what is inside them. What does [iCODE]return 0;[/iCODE] do? Do you want that inside your while loop? Also, I noticed before, in your other question, that these brackets don't seem to belong here. And if it was me, I wouldn't indent … | |
I've seen posts here that were posted in the wrong forum. Today there was one in the IT professionals forum that should be posted under HTML instead, and one with C code in the C++ forum. What do you think about creating a forum for members to report posts? Besides … | |
Re: Here is one way of reading from a text file and displaying the contents: [CODE] string sentence; string readSentence; //open file to read ifstream inData; inData.open("YourFileName.txt"); //read first line from the file getline(inData, readSentence); //show error if file not found if(!inData){ cout<< "Can't open input file.\n"; getchar(); } //while there … | |
Re: Not trying to butt in here, but I'd say that the error is on (or at least caused by) a line above the underlined one. A while loop should include brackets like: [CODE]while(condition){//bracket goes here //do stuff }//end loop[/CODE] | |
Re: ...maybe this should be in another forum? | |
Re: You're trying to calculate before you get the input. This line should go after you get the input to assign a value to price and quantity. [CODE]total = price * quantity * tax;[/CODE] | |
Re: some people use [CODE]system("cls");[/CODE] [URL="http://www.daniweb.com/code/snippet216428.html"]Here's[/URL] one example. | |
Re: What does the program do as opposed to what it's supposed to do? Are you getting any errors? Also you should probably use code tags: [code ]paste your code between tags like these, without spaces [/code ]. | |
Re: I do not know how to add new columns to a matrix either. This may not be the exact answer you are looking for, but I think it is similar to what you want to do: [CODE]//if you had a vector called nums, and a 2d array called ary, you … | |
Re: I would make a more general function instead of telling it the exact number of lines. [URL="http://www.cplusplus.com/doc/tutorial/files/"]Here's[/URL] a page with an example of how to check for end of file. | |
Re: You also still have the same 2 issues I mentioned the other day, in your other thread about the 2-d arrays (with this program). While I do not think this will affect your program (because you get the value with user input later) it is still not correct. [CODE] char … | |
Re: In addition to what Fbody said, you have an infinite loop. [CODE]char Y = 'Y'; //add 's around your char printintromessage (); getUserInput (Y); do { if (Y == 'Y' || Y == 'y') { printplayerinfo (numofgamesinseries, numofplayersonteam, i, j); //you'll have an infinite loop unless you stop it somehow … | |
This is my first question here. My latest assignment is to create a random walk program using a 2-d array. The program worked fine until I tried to put this code into a function: [CODE] for(int i = 0; i < 100; i++){ //reset field of flowers for each attempt … | |
Re: Could you use a while loop? Here is an example of a while loop that runs until a condition is met: [CODE]bool x=false; int num = 0; while(!x){//while x is false //test if(num ==5){ //if pass: cout<<"true"; x = true; } else{ //if fail: cout<<num<<endl; num++; } //should exit when … | |
Re: Do you mean that you don't want to have to press enter after each (one character) number is entered? If so, then yes it is possible. I'm sure I have seen this done a different way, but here is one way anyhow: [CODE] char num1, num2, num3, num4, num5; cout … | |
Re: If all your function does is display (print) the name of the shape, then why return anything? I'd just call it a void function and omit the return statement. Then when you call it, don't assign it to anything: [CODE]aFunction(); //call a void function //declare function as void void aFunction(){ … | |
Re: You don't even need to pass in grade or tot_quest into your functions if you are getting their values within the function. You can just define them within the function (if you don't need them anywhere else in the program.) [CODE] double calculateGrade(double grade) { int quest_corr, tot_quest; grade = … |