6,741 Posted Topics
Re: Do you honestly think that somebody is going to download a RAR file (possibly also installing a program that recognizes RAR files if they don't have it), extract your source from it, compile, link, run, debug, and tell you what to fix so that you can tell your friends that … | |
Re: >hope this helps. It doesn't. First, <math.h> isn't a valid C++ header anymore. Second, the correct header, <cmath>, has nothing to do with the .NET framework. | |
Re: [url]http://www.nist.gov/dads/HTML/littleOnotation.html[/url] Knock yourself out, and don't start two threads with the same question. | |
Re: >It is far better paractice to only include those symbols that you definitely want. Yes, though for such a small program it really doesn't matter. Namespaces don't become useful until you start working on projects with code from multiple sources (such as third party libraries). Up to that point, namespaces … | |
Re: You could pause after a certain number of results have been displayed, or write to a file and let your file reader handle the issue of scrolling. If you really want to do it yourself, and you want to use a console mode program, then you need several things: 1) … | |
Re: This doesn't sound like a programming or software design issue. You didn't even bother to mention what browser you use. They're all different you know. Since you're somewhat clueless, I'll assume Internet Explorer. Go to Tools, then Internet Options, then Clear History. >Basically i need to set on my computer … | |
Re: >he said that all who took the source compiled it But did he say how many [b]successfully[/b] compiled it? :cheesy: >and y is he commenting important parts, this is not normal! I wonder if you know what's normal and what's not to begin with. There are quite a few good … | |
Re: >Error: Unresolved external '_EDGE' referenced from C:\Graph\Test1.OBJ That's a linker error. It's telling you that you declared and used the name _EDGE somewhere in the program but neglected to defined it. When it comes to linker errors, the source files will compile, but they can't be linked together nito an … | |
Re: [code] string search; getline(cin, search); string line; while (getline(file, line)) { if (line.find(search) != string::npos) cout<<"Found!"<<endl; } [/code] | |
Re: [QUOTE=BinaryMayhem]there is an even better way to do that. after you compile the program for the first time, find the exe it creates. Right click the exe, click properties, click the program tab, uncheck the box "close on exit". then click apply! turning that off will leave the DOS window … | |
Re: >in C++ that's not allowed Are you sure? Maybe you should double check. It's allowed, though not very common because declaring a local structure restricts the scope of that structure to the function. That limits its usefulness. >is this program i wrote so far going to store all the data … | |
Re: >#include <string.h> Becomes: [code] #include <string> [/code] | |
Re: [QUOTE={{unknown}}]UP UP :sad: :sad: :sad: :sad: :sad:[/QUOTE] Bumping is considered bad form. I, and anyone who agrees, will now proceed to ignore you for the life of this thread. | |
Re: Start by reading the key: [code] #include <string> std::string key; std::getline(fin, key); [/code] Then work your way through each of the records: [code] while (true) { int n = 0; // Number of correct answers // Scores first for (std::string::size_type i = 0; i < key.length(); i++) { char tf; … | |
Re: >Why are the standard header files in C++ so non-standard? They are standard and well defined. >Particularly iostream seems to be the most dialectal. Any compiler is allowed to provide non-standard extensions. Any issues you have with extensions are your problem. | |
Re: >1) the difference between getline and gets(). gets is a throwback from ancient C, is impossible to use safely, and should never be used in C++. getline is okay because you can supply a limit for how many characters to read. >2) why sometimes when getline is used along with … | |
Re: >if you then just press enter at the character search prompt you will find the \n. That's reasonable (and expected) behavior. Let's say you want to test for exceptionally long lines: [code] while (fgets(buffer, sizeof buffer, stdin) != NULL && !check(buffer, '\n')) { /* Append buffer to a dynamic string … | |
Re: >Spend some time with your editor to look at the iostream header. Spend some time with the C++ standard. iostream isn't required to include cstdio or stdio.h, so your code exhibits undefined behavior. >The one that comes with Dev-C++ Not everyone uses Dev-C++. | |
Re: If you're going to do using namespace std, put it immediately after your includes. As it is, you're using ifstream and ofstream without qualifying the namespace. | |
Re: Pick three random viruses and figure out a way to find them through their signatures. The first task is one of research. | |
Re: First you have to include the standard header for students such as yourself: [code] #include <Imalazybastard> [/code] Then you need to call the following function: [code] do_everything_I_want_by_reading_my_mind(); [/code] That should get you started. :) | |
Re: >while ((product = cin.get()) != EOF) Change this to: [code] while (cin>> product) [/code] And remove the first request for input outside of the loop. | |
Re: First, place this after your includes: [code] using namespace std; [/code] Then look for typos. Recompile and we'll go from there. p.s. It couldn't hurt to read my reply to your other thread. Notice how I used T(), not T, for default construction of a value of template parameter type. | |
Re: >How would you open the array of files or write to the array of files? Show us your code. What you're doing sounds very tricky and error prone. I'd like to make sure that you're doing it right. | |
Re: [code] void IntArray:: init ( const T *data, int sz) { assert( (0 <= sz) && (sz <= MAXINT)); d_num_elements = sz; if ( 0 == d_num_elements ){ // if no elements in array d_array = NULL; // array points to NULL } else{ d_array = new T [d_num_elements]; } … | |
Re: Remove unnecessary parts (ie. unrelated to your problem) from the program and then post it here. Many people are unwilling to download attachments because it's an inconvenience when most of the time we can tell you what the problem is at a glance. | |
Re: >I am learning C while reading Robert Sedgewick's Algorithms in C (3rd Ed). Please do not follow the example code from that book. The concepts and descriptions are exquisite, but the code SUCKS! It's a poor translation from Pascal, with errors and bad style on every page. You would be … | |
Re: [QUOTE=mad_cow01]Hi i'm new here and tommorrow i'll be doing some project in computer science so i need a template/outline of a triangle.h file, thanks in advance ; )[/QUOTE] And you expect anyone to have a clue what you're talking about? triangle.h isn't a standard header, therefore it could be [b]anything[/b]. … | |
Re: >I'm desperate, and it's due tonight. Sucks for you. I guess you should have paid attention in class. >I really don't know how I would go about doing that. You have a dollar amount. Subtract 20 until you can't anymore and count the number of times you subtracted 20. Then … | |
Re: >but why this sample program doesn't work??!! Integer literals are just that, integers. If you want a long literal, suffix it with L. If you want an unsigned long literal, suffix it with UL. >void main(){ main returns an int, it always has and always will. | |
Re: >it always seems to return 1 as a reult. I would imagine that's because both operands are non-zero. You're using the logical AND and logical OR rather than the bitwise AND and bitwise OR. The logical operators are && and ||, and the bitwise operators are & and |. >It … | |
Re: >if any one knows of an easier and/or different way please let me know An easier and different way is to just read all of the numbers and compare. At any given point it looks like you only need the current number and the previous number, and how much less … | |
Re: Three words: intermediate data structure. For example, read each record from the first file and save it in an array. Then sort the array and write it to the second file. | |
Re: Option 1: Write your own functions to manipulate numbers represented as a string. Option 2: Use a library that does Option 1, such as [url=http://www.swox.com/gmp/]GMP[/url]. | |
Re: >/* rand() is defined through the header math.h, as purpleposeidon said */ stdlib.h, not math.h. >The warnings don't prevent compilation but errors do! The warnings should be addressed though. They're there for a reason. | |
Re: >My teacher told me that tutoring was my problem and good luck basically You have a poor teacher. I suggest you report him, because he's not doing his job. >Anyone please please please help me. It may sound harsh, but some people just aren't cut out for programming. >Can some … | |
Re: >I have set a goal of 6 months to do best learning c++ and java So in 6 months you expect to learn both C++ and Java to the point where you could use them professionally? Answer me this: What experience with programming do you already have? | |
Re: 1) No, and maybe. 2) Say that the parameter shouldn't be changed and say that the method won't change the state of an object. 3) Yes, but only for objects that aren't dynamically allocated. For dynamic allocation, the destructor is called when the memory is released. 4.1) Close enough. 4.2) … | |
Re: >What should should i adopt to achieve my goal. Use the Win32 API instead of trying to break your computer with ASM. Specifically, look up SetConsoleCursorPosition on MSDN. | |
Re: >Can anyone point me the direction of getting a linux verision that comes with a .cpp compiler? g++ comes standard with every Linux distro I know of. | |
Re: [code] // Class.h class C { int i; public: C(); public: int geti() const; }; [/code] [code] // Class.cpp #include "Class.h" C::C(): i(0) {} int C::geti() const { return i; } [/code] [code] // main.cpp #include <iostream> #include "Class.h" using namespace std; int main() { C c; cout<< c.geti() <<endl; … | |
Re: Okay, what's your exact problem? I've already been kind enough not only to refrain from flaming you for posting in the [b]wrong forum[/b], but also to give you a viable solution to your last problem. I don't have a great deal of patience, so I highly recommend moving your thread … | |
Re: Keeping it simple: [code] using System; class City { private string name, state; private long population; public City(string name, string state, long population) { this.name = name; this.state = state; this.population = population; } public void relocate(string name, string state, long population) { this.name = name; this.state = state; this.population … | |
Re: >else i++ Copy and paste can be a bitch. :D Add a semicolon to this line. | |
Re: assert is a macro that's defined in the <cassert> header. | |
Re: [code] #include <iostream> using namespace std; class IntArray { public: IntArray ( int sz = 10 ); IntArray ( const IntArray &x); virtual ~IntArray(); int size () const; int &operator [] ( int i ) const; private: int d_num_elements; int *d_array; private: void init (const int *x, int sz); }; … | |
Re: >The strcpy is valid. I was unaware that indexing an uninitialized pointer and then passing the contents of it (another uninitialized pointer) to strcpy was valid. Since I trust my knowledge more than I trust your knowledge, I'm going to say that you're wrong. >The question is how to free … | |
Re: [code] #include <algorithm> #include <iostream> #include <vector> using namespace std; template <typename T> inline T mid(const T& a, const T& b, const T&c) { T init[3] = {a, b, c}; vector<T> v(init, init + 3); sort(v.begin(), v.end()); return v[1]; } int main() { cout<<"The middle number is "<< mid(12, 14, … | |
Re: This will work until you try to do just about anything else. [code] #include <iostream> using namespace std; template <typename T> class Complex { protected: T real, imag; public: Complex(T real_init, T imag_init) : real(real_init), imag(imag_init) {} public: template <typename U> friend U get_real(Complex<U>& c); template <typename U> friend U … | |
Re: >how do floating numbers work exactly There's an [url=http://cch.loria.fr/documentation/IEEE754/ACM/goldberg.pdf]ebook[/url] out there that describes floating-point in detail. It's also over 40 pages of densely packed gibberish. Do you want to be more specific so that I don't have to summarize [b]everything[/b]? >i cant seem to understand there purpose They're useful if … |
The End.