- Strength to Increase Rep
- +9
- Strength to Decrease Rep
- -2
- Upvotes Received
- 17
- Posts with Upvotes
- 16
- Upvoting Members
- 15
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 3
I'm a student, freshly passed out of school, and waiting for college to begin, and very, very interested in programming, 'specially in C++. I also love the realm of Web Development, and enjoy animation (in-fact, I'm now taking a course on it) :D
- PC Specs
- System: Linux, Ubuntu 10.04 LTS Lucid Lynx Computer: Intel(R) Pentium(R) 4 CPU 2.66 GHz 1024 MB RAM…
Re: [CODE=cplusplus] #include <cstdlib> #include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]){ string line = ""; int lineLength = 0; int shiftValue = 0; int asciiValue[lineLength]; // <- Problem1 char cipherLine[lineLength]; // <- Problem 2 ifstream plainText ("plain.txt"); ofstream cipherText ("cipher.txt"); cout << "Please enter a shift … | |
Re: And I'm listenin to: [ICODE]Another Day In Paradise by Phil Collins[/ICODE] | |
Re: A quick glance at the definition of the overloaded `istream` and it's clear that you've missed the fact that dividing two integers will lead to a loss of precision. Change `int b;` to `float b;` and you're good to go (provided `class fraction` stores a fraction as a floating-point value, … | |
Re: hi, Could you tell us what the message is in the "send error report to Microsoft" dialog? | |
Re: I tried the same code on the same IDE (same version as well), with the same compiler, running under Windows XP, and it executed perfectly. Check the integrity of your copy of GCC, and if it isn't, try installing it again. | |
Re: To output just a certain part of a string, you'll need to use [ICODE]std::string[/ICODE]'s [ICODE]substr(size_t pos, size_t n)[/ICODE], which essentially extracts a part of the whole string, as specified by its parameters, where [ICODE]pos[/ICODE] is the starting index and [ICODE]n[/ICODE] represents the number of characters to extract after [ICODE]pos[/ICODE]. An … | |
Re: Pointers aren't required, simply change the prototype & definition of the function [ICODE]get_tp()[/ICODE] to something like: [CODE] int& get_tp() { return myint; } [/CODE] However, If you want to maintain const-correctness (and I think that that's usually a good idea), then you don't have to change the function at all, … | |
Re: To answer your question: If you have overloaded the said operators in your class definition, then yes, they will be called automatically. For the second part of your question: In C++, it can be generally assumed that all such statements follow operator precedence. As both binary addition ([ICODE]+[/ICODE]) and subtraction … | |
Re: If the code below illustrates your question, then yes, it is possible, even necessary for us to call the constructor in the initializer-lists from the subclass. [CODE=cplusplus] class Base { public: Base(std::string text, int blah) : mText(text), mBlah(blah) { /* ... */ } // Some other methods private: std::string mText; … | |
Re: Using [ICODE]gets()[/ICODE] is usually a bad idea from the start (See [URL="http://www.gidnetwork.com/b-56.html"]this[/URL] page for more information), but this problem is usually caused by stray characters still present in the buffer. [ICODE]gets()[/ICODE] will simply take those characters as input and it seems as though your program is skipping input. It can … | |
Re: Well, I can't say much just by looking at your (incomplete)code, but I wonder exactly how you are [I]passing[/I] the vector to [ICODE]main()[/ICODE] or any other function, as [ICODE]vector<string> myvector;[/ICODE] remains a [B]local[/B] variable, and looking at your definition of the function [ICODE]LoadFile()[/ICODE], it doesn't return anything. To answer your … | |
Re: Try this: [ICODE]temp->link(num_people, head);[/ICODE]. You've declared the variable [ICODE]temp[/ICODE] to be a pointer, but you are accessing its member function as though it were a normal object and not a pointer object. See [URL="http://msdn.microsoft.com/en-us/library/b930c881%28VS.71%29.aspx"]this[/URL] for more info. | |
Re: I think you're looking to dynamically implementing your arrays. See [URL="http://www.cplusplus.com/doc/tutorial/dynamic/"]this[/URL] for more information. There's also a few points about your code: [B]1.[/B] Your bubble-sort can be improved with a flag to reduce the number of iterations required to sort it. See [URL="http://www.mathbits.org/MathBits/CompSci/Arrays/Bubble.htm"]this[/URL] for an example. [B]2.[/B] Your code could … | |
Re: This should help: [URL="http://www.daniweb.com/code/snippet217375.html"]Code Snippet[/URL] Also, the function [ICODE]itoa()[/ICODE] is not defined in the ANSI-C++ standard, so it may not be supported on all platforms. Hope this helped | |
Re: To answer your questions: [B]1.[/B] Just do it. Start programming. I'm sure it wouldn't be that huge a leap for you coming from a PHP/Java background. Start with the humble "[B]Hello World[/B]" program, and head out from there... [B]2.[/B] A quick search on [B][I]google[/I][/B] or [B][I]sourceforge[/I][/B] will provide you with … | |
Re: A good first attempt :) From your code, I can suggest some improvements: 1. [B][COLOR="Red"]NEVER[/COLOR][/B] use [ICODE]system("pause");[/ICODE]. See [URL="http://www.gidnetwork.com/b-61.html"]here[/URL] for more information. Use [ICODE]std::cin.get();[/ICODE] instead. 2. To make typing the code shorter, you should always look to reduce repetitive code, like the following statements: [ICODE]cout << "Enter two Real numbers." … | |
Re: Do you have some code to show for what you say you've done? I'm sure you know by now that we here at Daniweb do [B]NOT[/B] provide help without the OP showing some sort of effort. If you post your code, maybe we can point you in the right direction … | |
Re: This is usually caused by your application's manifest file, which might refer to a wrong version of the redistributable VC90.CRT/MFC/ATL dll package, or these packages may not be installed on the traget machine. If you haven't embedded your application's manifest file, then you can see a line in the manifest … | |
Re: HmmMMMmmm... IMHO, I think this can be done in a simpler way, by using two loops instead of one, that iterates over the entire range of your 2D array. If you have worked with matrices in C++, then you'll know what I'm talking about. Now in C++, array indices start … | |
Re: First of all, I think that there's a simpler way to achieve what you are trying to do here. The algorithm for finding factors of any given number goes something like this: (In pseudo-code) [CODE=cplusplus] maximumDivisor = squareroot of number; // The maximum possible divisor for(x = 1 till x … | |
Re: If your file structure is consistent to the sample you provided, you could also try: (In pseudo-code) [CODE=cplusplus] { // Inside your file-reading loop Matrix[num][num] = floatnum; // where num = line number } [/CODE] Or you could use a class to represent your matrix, as daviddoria suggested, which would … | |
Re: @Patces: Please refrain from hijacking threads. If you have a question you can't find a solution to, please start your own thread. Also, we can only help you if, and only if, you have put in some sort of effort in, i.e show us some of the code you've been … | |
| Re: Hi, Well you're right, there seems to be no point in the message. Check the browser you are viewing the page with. Also it could be that your web server is blocking it. |
Re: More specifically, this is your problem (the one in bold): [ICODE]bookinfo([B][COLOR="Red"]int&[/COLOR][/B], char [51], char [14], char [31], char [31], char [11], int&, double&, double&)[/ICODE] Try changing it to just [ICODE][B]int[/B][/ICODE], as [ICODE]int&[/ICODE] is almost equivalent to [ICODE]int*[/ICODE], which is not the type of the first argument in your function prototype. | |
Re: [B]>>[/B] Why it is necessary? Well, it shouldn't be... I tried the code separately on both GCC and minGW compilers, and both compiled well and didn't complain... Try adding the statement [CODE=cplusplus]using std::ostream;[/CODE] and try again... | |
Re: [B]>>[/B] Now, if after reading the code the output isn't strange to you then my understanding of C++ is probably very wrong and I'm missing something obvious. Well, as you've rightly guessed, the output is as expected... :) You may now be wondering why this happens - well, when you … | |
Re: Why not try this: [code=c++] #include <iostream> #include <fstream> using namespace std; int main() { ifstream iptilvar; iptilvar.open ("ip.txt"); //open filestram iptilvar.seekg(0, ios::end); long size = iptilvar.tellg(); // Get the size of the file iptilvar.seekg(0, ios::beg); char *buffer = new char[size]; // Make a buffer big enough to hold the … | |
Re: I'm not sure, but try: [CODE=cplusplus]real x = {1.};[/CODE] With this, you wouldn't need to overload any operator... Hope it helped! | |
Re: [QUOTE=jonsca;1061542]Your main should never return void, [I]always[/I] an int. You should have return 0; at the end. Using another return statement in the midst of your [code] if (w==1) cout<<"You win!"; else if (w==2) cout<<"You lose!"; else if (t==9&&w==0) cout<<"Tie Game"; [/code] might be a good idea. I haven't familiarized … | |
Re: Okay, before I answer your question, a few things need to be cleared. In all the code I've seen till now, [ICODE]<ionstream>[/ICODE] is by far the most striking alternative to the known, and beloved [ICODE]<iostream>[/ICODE] (although, I must admit, [B]ion[/B]stream sounds cool). And another thing is the [ICODE]cin[/ICODE] statement at … |