- 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…
99 Posted Topics
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 … | |
Re: Okay first things first... What exactly are you trying to achieve with this code? Secondly, You can get rid of some of these errors: [COLOR="Green"][B]1.[/B][/COLOR] [COLOR="Red"]17: error: `islowerCase' undeclared (first use this function)[/COLOR] You'll have to write a function definition before attempting to use the function, as it is defined, … | |
Re: First of all, I would highly recommend you go through [URL="http://www.cplusplus.com/doc/tutorial/"][COLOR="Green"]this[/COLOR][/URL] tutorial, that'll help you brush up some basics in C++, before starting to make your own programs. You've got some major problems in the code, like your [ICODE]for[/ICODE] loop, which has a statement missing. Even before that, there's logically … | |
Re: Try adding a [ICODE]cin.ignore();[/ICODE] statement before each of your inputs. See this: [URL="http://www.cplusplus.com/reference/iostream/istream/ignore/"]http://www.cplusplus.com/reference/iostream/istream/ignore/[/URL] Incidentally, its better you don't use [ICODE]fflush(stdin);[/ICODE]. See [URL="http://www.cprogramming.com/faq/cgi-bin/smartfaq.cgi?id=1043284351&answer=1052863818"]here[/URL] for more info. | |
Re: You could try this: [CODE=cplusplus] FILE *in; char line[1000]; char *token; in = fopen(argv[1],"rt+"); if ( in == NULL) exit(1); int i=0; // Read the first line... move the file pointer to // point to the end of the first line. Note that the // definition for end-of-line is the … | |
Re: I'm not sure whether this is what you are looking for, but try this: [CODE=cplusplus] infile.seekg(0, std::ios::end); long fileEnd = infile.tellg(); long counter = 0; while(counter != fileEnd) { // do something ++counter; } // end while [/CODE] What's happening here is that you make the "get" pointer to point … | |
My implementation of the [ICODE]strcmp[/ICODE] and [ICODE]strncmp[/ICODE] functions. I don't think that it is very efficient, but have managed to get both the functions' execution times to [ICODE]0.01 s[/ICODE] (At least, this is the value my profiler gives me). Enjoy! :) | |
Re: Nice code! But maybe the function name [ICODE]pow[/ICODE] should be changed, to avoid any ambiguity caused if anybody chooses to include [ICODE]<cmath>[/ICODE] with that :) ... | |
These functions, to some, may seem trivial, but many people have queried in the forums on this topic numerous times. The functions are templated, so that it can accommodate any data-type that the user wishes to use (For example, the same function can be used for converting variables of type … | |
Oh no!... can this be deleted? I don't know what happened... I was typing in a new thread, and it got posted! I'm extremely sorry... | |
Re: Are you sure that this program compiles? You seem to have used [ICODE]string[/ICODE] in your code, but you haven't included [ICODE]<string.h>[/ICODE] at all...! Apart from that, could you tell us what IDE/compiler you are using... or does the code assume all objects to belong to the namespace [ICODE]std[/ICODE], because I … | |
Re: Your output is expected, and here's the [URL="http://www93.wolframalpha.com/input/?i=sin(3.141592653589793)"]result[/URL] of the same when I tried it on Wolfram's Online Math Engine. [URL="http://www.cplusplus.com/reference/clibrary/cmath/sin/"]Here[/URL]: The sin() function prototypes | |
Re: [B]>[/B] What am I doing wrong??? A [B]lot[/B]! .... but nothing that you can't learn from, with a little bit of [U]effort[/U]... Your [ICODE]struct[/ICODE] contains 2 functions, both of which can [B][I]directly[/I][/B] access the other [ICODE]struct[/ICODE] members. Also, every instance of your [ICODE]struct[/ICODE] have available to them, your two functions … | |
Re: Have a look at this: [URL="http://en.wikipedia.org/wiki/String_theory"]http://en.wikipedia.org/wiki/String_theory[/URL] If that theory (String Theory) can be proved, then the statement (made by the OP), cannot be proved wrong, at least from my (slightly unintelligent) inference of that theory. | |
Re: Firstly, I am [B]not[/B] going to do the functions for you, but I'll show you where you are going wrong, and give you ideas on how to correct them. The following code is extracted from your program's [ICODE]case 4:[/ICODE], with added [ICODE]//<MARKER (x)[/ICODE] comments to indicate the lines that are … | |
Re: [B]>[/B] [B][COLOR="Green"]To the OP:[/COLOR][/B] You say that this function - [ICODE]cio_putstr()[/ICODE] returns a [ICODE]void[/ICODE]. If this is so, then just [B][I]why[/I][/B] is it in your [ICODE]for[/ICODE] loop as a test expression? And could you explain what it - [ICODE]cio_putstr()[/ICODE] - is supposed to do? [B]>[/B] [B][COLOR="Green"]To Ancient Dragon:[/COLOR][/B] I read … | |
Re: [QUOTE=Salem;865335]Or Psychopath? [attach]10078[/attach] Lots more here. [url]http://www.telegraph.co.uk/travel/picturegalleries/5278200/Sign-language-week-48.html[/url] Made me laugh, in the midst of despair with all the greedy trough feeding SCUM [url]http://www.telegraph.co.uk/news/newstopics/mps-expenses/5298065/MPs-expenses-Four-ministers-who-milked-the-system.html[/url] [url]http://www.telegraph.co.uk/news/newstopics/mps-expenses/5292959/MPs-expenses-Ten-extraordinary-claims.html[/url] And so on ad nauseum. These fuckers should be spending all their energies on running the country (instead, just ruining it), not running around finding all … | |
Re: [B]>[/B] where the city name next to weight is should be in alphabetical order. What exactly do you mean by this statement? What "weight" are you referring to? And by "city name should be in alphabetical order", did you mean that the last line(for example) in your Output should look … | |
Re: [QUOTE=saalvi;876519]Problem Statement: Dynamic memory allocation/reallocation of an Integer array. Detailed Description: Write a program in which you have to: 1. Dynamically allocate an array of integers. 2. Take array size as input from user and allocate memory according to this size. 3. Take values of array elements as an input … | |
Re: [QUOTE=vs.vaidyanathan;873743]i am using Visual C++. its for 3-D reconstruction from multiple views. I have image coordinates of the same point from two cameras. Their calibrations are known. So i should be able to get the world coordinates. having got that, how do i implement the z coordinate in my output … | |
Re: This might be worth a shot: As you are going to only declare an object of the class [ICODE]GLCursor[/ICODE] in your class [ICODE]FLGLWindow[/ICODE], and are [B]not[/B] going to use its member functions directly (i.e, you are going to use the methods provided by [ICODE]GLCursor[/ICODE] through the object you created in … |
The End.