- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 5
- Posts with Upvotes
- 5
- Upvoting Members
- 5
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: [QUOTE=Tommybb;759674] .... Are there any good online sources you all would recommend for a beginner? Thannks, Tom [/QUOTE] The following site is good, but of course won't cover much. I personally learn only from the internet, and make programs for fun and complex calculations. Whenever I want to do something … | |
Re: Binary operations are operations between two variables (like a+b, a-b, a^b, a/b etc.). Unary operations are operations on one variable (a++, a-- ...) | |
Re: Look at this link: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385[/url] The last method is probably what you're looking for. | |
Re: In case you like math, you can try the following site: [url]http://projecteuler.net[/url] | |
Re: Two things: First, you forgot to add the first number to the total. Second, with [icode]while(!source_file.eof())[/icode] you run through the last line twice. Therefore, instead of 10+20+40+10+12 = 92 you get 20+40+10+12+12 = 94 | |
Re: Look at the code here: [code] if (pos [color="red"]![/color]= -1) { goto badsearch; } [/code] I think you meant: [code] if (pos [color="red"]=[/color]= -1) { goto badsearch; } [/code] Another thing is that string::search() returns string::npos if the search function does not find what it was told to find, and … | |
Re: I don't understand - why do you have the numbers input as 'int'? Why don't you have the numbers input directly into a string and then use the operator [] to move through the digits and count values? I think it could be much more efficient - just run a … | |
Re: In addition to the above posts: 1) The user has no chance to input the second number. Better add [icode]cin>>dsecondnumber;[/icode] after the user is told to input the second number. 2) In your [icode]case[/icode] statements the output is always [code]cout<< " The Answer is:"<< dfirstnumber << (operator) << dsecondnumber << … | |
Re: Why not use the built-in [URL="http://cplusplus.com/reference/algorithm/random_shuffle/"]random shuffle()[/URL] function from the header [icode]<algorithm>[/icode]? | |
Re: Look at your while loop: you closed it before it started: [icode]while(ordnum != 99999);[/icode]. Just remove the semicolon right after the [icode]while(ordnum != 99999)[/icode] and everything should be fine ;) | |
Re: Change this line: [icode]cout<<fly.freeSeat;[/icode] to this: [icode]cout<<fly.freeSeat[color="red"]()[/color];[/icode] Remember that [icode]freeSeat[/icode] is a function ;). Edit: I guess Narue was faster :) | |
Re: Add [icode]Password="";[/icode] before [code=c++] while(encrypt != 13) { Password.push_back(encrypt); cout << '*'; encrypt = _getch(); } [/code] That's because when the user enters a wrong password you keep [icode]Password[/icode] with the wrong password and just add characters to it. You need to empty it before. | |
Re: That's weird - it works perfect for me. | |
Re: What about a linked list? Or alternatively, you could store all the class instances in an array with as many elements as the the user inputs, and to check which instance has the student's ID run a loop through all the indexes. An example to make it all clearer: [code=c++] … | |
Re: The function is expecting an int[] (array/pointer) type and you pass an int, instead you should write the function as: [icode]void bookInfo(char[14],char[51],char[31],char[31],char[11],int,double,double);[/icode] It would also be better if you used strings from the <string> header instead of arrays of [icode]char[/icode]s. | |
Re: [QUOTE=iammfa;844199]Hi all, what is the bug in the following code: [code=c++] #include <iostream> #include <string> int main() { string str = "Hello World!" cout << str << endl; cout << float x = 5.0f * str << endl; int 65Num = 65; cout << "65Num = " << 65Num << … | |
Re: [code=c++]outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;[/code] You output what outputFile returns. This line should be [code=c++]outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;[/code] | |
Re: I'm guessing it's because of the getline() function. When I replace the [code=c++] if(AWUTD=='y'||AWUTD=='Y') { cout<<"Please Specify:"<<endl; getline (cin, AWUTDspecification); } [/code] with [code=c++] if(AWUTD=='y'||AWUTD=='Y') { cout<<"Please Specify:"<<endl; cin>>AWUTDspecification; } [/code] it works better. I suggest that you read the following ReadMe thread: [URL="http://www.daniweb.com/forums/thread90228.html"] How do I flush the input … | |
Re: [QUOTE=vmanes;761217]Where do you get an 8 byte long int? It's 4 bytes everywhere I've seen.[/QUOTE] A [icode]long long int[/icode] (signed/unsigned) is 8 bytes. [icode]cout<<sizeof(long long)[/icode] | |
Re: Please use code tags. Otherwise it'll be hard for us to tell you on which lines your mistakes are. | |
Re: You'll have to re-write everything. Just make a new file, read the file you want, and write the lines to the new file, with the changes you want. Afterwards, erase the old file and rename the new file to the old file's name. There's something similar (erasing a line from … | |
Re: What do you mean? Do you want the blocks to appear in lines, like that?: [code] ****** ****** ****** ****** ****** * * * * * * * * * * * * * * * * * * * * ****** ****** ****** ****** ****** [/code] If you do, … | |
Re: It doesn't matter that 'i' doesn't exist when main() ends and the thread is using it, simply because when main() ends the whole program shuts down, including the threads. | |
Re: The computer doesn't recognize when a cell is occupied because you didn't tell it to. You're making a check only on board[5][x]. You should use a loop to check which is the the highest place available and just then test it. | |
Re: A much clearer method would be [icode]rand()%x[/icode], where x is the number you want. For example, [icode]rand()%7[/icode] will return a random number between 0 and 6, and the code [icode]rand()%7+1[/icode] will return a value between 1 and 7. If you want the numbers to be as random as possible, add … | |
Re: [url]http://www.daniweb.com/forums/post31214.html[/url] This link should help you. It teached me well how to use ifstream objects. | |
Re: We won't do your homework. You should provide us some code so we can know you've at least tried. [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: Why should a constructor fail? When you declare a constructor, all the instances of the class will have to use it, or variations of it (if you declare some). | |
Re: [code=c++] for(x=0;x<s.length();x++) { if((s[x]>'9' || s[x]<'0') && s[x]!='.') { input_type=IS_STRING; break; cout<<" Its an integer "; } else if(s[x]=='.') { if(!DotReached) DotReached= true; else { input_type=IS_STRING; cout<<"ITs a Float"; break; } } } [/code] Line 6: How do you want the program to output "It's an integer" when there's a … | |
Re: I think it would be much smarter to use the built-in function from <algorithm> header file -- random_shuffle(): Run a loop and insert to the array all the numbers between 1 and 10,000, then call random_shuffle() to shuffle them. An example code: [code=c++] #include<iostream> #include<fstream> #include<algorithm> using namespace std; int … |