6,741 Posted Topics

Member Avatar for SquirrelProdigy

>What are your recommendations? Download Bloodshed's Dev-C++. If you like it then it should suffice for the time being and not cost you anything.

Member Avatar for Narue
0
182
Member Avatar for kittie

>char [size] name; Good suggestion, bad code. You seem to be mixing and matching features of C++ and Java to create something completely incorrect for both. Try this instead: [code] char name[size]; [/code] Where size is a suitably defined constant value, in this case 5.

Member Avatar for Narue
0
179
Member Avatar for winbatch

For somewhat obscure reasons, operator<< should be a non-member function: [code] ostream& operator<< ( ostream& out, const Log& log ) { log.writeLog ( out ); return out; } [/code] If Log doesn't have a public interface that allows everyone to write the log somewhere, you'll need to make the function …

Member Avatar for Narue
0
2K
Member Avatar for Acidburn

I would imagine that you initialize encryption with asterisks, right? So let's walk through the execution with that assumption in mind: [code] for ( int i = 0; i < 5; i++ ) [/code] You create i and set it to 0. Since i is less than 5, the body …

Member Avatar for Dave Sinkula
0
185
Member Avatar for SquirrelProdigy

cin's operator>> uses whitespace as a delimiter: [code] string s; cin>> s; // Type "John Doe" cout<< s; // Prints "John". "Doe" left in the stream [/code] >I tried flushing the input buffer with cout.flush() What made you think that calling the flush member function of an output stream would …

Member Avatar for subtronic
0
272
Member Avatar for SHETS10

This is a simple program. Are you trying to get other people to do your homework?

Member Avatar for Narue
0
67
Member Avatar for winbatch

Code tags don't help much if your code isn't formatted to begin with. >what is the proper code inside the < operator? That depends on the needs of the class. Does it make more sense to compare by first name, last name, or both? How you define operator< depends heavily …

Member Avatar for Narue
0
452
Member Avatar for moderate_rock48

>If linux is so great and so much better than microsoft, then how come each >newer version becomes more and more like Windows? Linux vendors want the desktop market, so they have to dumb things down enough to entice the average Windows user. Of course, that's just my opinion as …

Member Avatar for Catweazle
0
527
Member Avatar for silicon

Congratulations, you've just discovered the difference between theoretical upper bounds and real world implementations. In theory, merge sort is slightly faster than heap sort. In practice, the merge sort algorithm could be implemented poorly (or naively) and heap sort will blow it away.

Member Avatar for subtronic
0
173
Member Avatar for nizar4445

When you need to read an unknown number of records, you have three choices: 1) Read and process one record at a time: [code] struct student stud; int i; while (fgets(stud.name, sizeof stud.name, in) != NULL) { for (i = 0; i < 5; i++) { if (fscanf(in, "%d", &stud.marks[i]) …

Member Avatar for nizar4445
0
271
Member Avatar for bsrivastava

>Well u can always use STL's "for_each" for efficiency, readability, portability & usability. for_each isn't nearly as useful as the propaganda suggests. Also, for_each would be a poor solution to the issue that this tip covers. A better solution would be generate_n, but that's still not as concise and easy …

Member Avatar for Narue
0
220
Member Avatar for the b
Member Avatar for winbatch

What you want to do is not possible in standard C++. You seem to think that a file stream knows if the external device is available if you remove it between construction and destruction of the stream. In reality, all you're doing is invoking undefined behavior by writing to a …

Member Avatar for subtronic
0
2K
Member Avatar for nizar4445

>#include <stdio.h> >#include <iostream.h> >#include <stdlib.h> This are no longer valid C++. Use this instead: [code] #include <cstdio> #include <iostream> #include <cstdlib> using namespace std; [/code] >void main() No! void main is not, and never has been, correct C++. main returns int: [code] int main() [/code] >int ave, 1st, 1:2, …

Member Avatar for sinrtb
0
307
Member Avatar for The Unreal Wolf

An IP is a four byte address representing a network node (ie. a computer or network) under the internet protocol (hence the name, IP). IPs are used for locating other nodes on a network to establish a communication link. Without an address, it would be very hard to find a …

Member Avatar for The Unreal Wolf
0
179
Member Avatar for innocent_one
Member Avatar for metalking5

Let me spell something out for you nice big letters: [SIZE=7][B]We will not write your program for you.[/B][/SIZE] If you want help, we'll help, but freebies are not help.

Member Avatar for Narue
0
81
Member Avatar for kittie

>don't I have it declared in the float line?? No. If you had preceded it with a comma instead of a semicolon then yes: [code] float qty=0, val=0[COLOR=Red][B][SIZE=7];[/SIZE][/B][/COLOR] price=0; [/code]

Member Avatar for kittie
0
210
Member Avatar for bobr_1013

It's hardly a strange problem since everybody sees it when learning C or C++. getline reads characters until a newline character is encountered, but cin>> leaves newlines on the stream. So a cin>> followed by a getline will typically cause problems. >As always, I appreciate your help Apparently not enough …

Member Avatar for vegaseat
0
232
Member Avatar for belama
Member Avatar for fatallah

That's your last chance, "dear". You've broken rules left and right while not contributing anything useful to the forum [b]despite[/b] multiple warnings through both thread and PM.

Member Avatar for Narue
0
266
Member Avatar for peter_budo

1) You need to include <string> because you try to use the string class. 2) You need to qualify each use of string with std::. 3) You can't initialize arrays in a class declaration. 4) Because of 3, you must supply a size for the arrays.

Member Avatar for Narue
0
161
Member Avatar for hessa

>the search shoud work like this Okay...and what [b]does[/b] it look like? Sorry, but I'm not nearly interested enough in your problem to compile and debug your code to find out what's wrong. You'll have to tell me what your problem is to get help. However, I [b]am[/b] interested enough …

Member Avatar for hessa
0
241
Member Avatar for subtronic

Allow me to paraphrase and offer an official response. >"C and C++ are different languages" Yes they are. Properly written C will likely break when compiled as C++ for any non-trivial program, and properly written C++ is barely recognizable as "something like" C. >"Most C++ looks like C" Yes, but …

Member Avatar for subtronic
0
296
Member Avatar for nathanj99

>Just get garbage when I write it to disk. You said you were using fstream. Would that be fstream::operator<<, or fstream::write? Since Borland supplies you with AnsiString, it makes sense that they would also provide an overloaded operator<< for it as well. At the very least, IIRC, AnsiString has a …

Member Avatar for Narue
0
310
Member Avatar for jewboy

>people form biased opinions of people based on where they're located. Perhaps, but it's more likely that one would form a biased opinion based on one poorly worded post, a first impression in the Introduction forum, or any number of trivial things that occur often. I think the entire issue …

Member Avatar for JJ___
0
321
Member Avatar for hostingonline

>I Dont know why i like this forum It's the girly purple. Everyone loves girly purple, even those who say they don't like girly purple. :)

Member Avatar for JJ___
0
139
Member Avatar for nathanj99

>I have two problems with this. No, you have one big problem. Binary reads and writes are undefined on non-POD classes, such as AnsiString. You would be better off avoiding binary oriented files until you know what the pitfalls are.

Member Avatar for Narue
0
160
Member Avatar for Acidburn

Bike (incorrectly) derives from Wheel, so you need to supply a constructor call to the base class. If one isn't make explicitly, it's provided for you using the default constructor. Try this: [code] Bike::Bike(int f, int b): Wheel(0), front(f), back(b) {} [/code] Of course, 0 is probably not an appropriate …

Member Avatar for Narue
0
197
Member Avatar for Valmont

>It isn't even for me. You sure used "I" a lot if it's not for you. You also seem to care quite a bit even though it's not for you. This strikes me as one of those "Hey, Doctor, my friend has this embarrassing problem" stories. :D It seems to …

Member Avatar for Narue
0
170
Member Avatar for tyczj

[code] #include "pctimer.h" ... pctimer_t begin = pctimer(); /* Code that you're timing */ printf ( "Time elapsed: %f\n", pctimer() - begin ); [/code]

Member Avatar for tyczj
0
284
Member Avatar for nathanj99

If you try to write the structure object to a file, you'll basically be doing a byte-by-byte copy to the file. That's bad because one of your members appears to be a non-POD type (String). A byte-by-byte copy on a non-POD type will likely not work, and because it's undefined …

Member Avatar for Narue
0
211
Member Avatar for feda

It's a good thing you thanked us in advance, because you certainly wouldn't thank us after we told you that this isn't rent-a-coder-for-free.com.

Member Avatar for Narue
0
194
Member Avatar for apurva agarwal
Member Avatar for Rose Aashii

>plz tell smething more abt my problm. How about we skip the part where I call your code crap with examples and I just give you a better version: [code] #include <iostream> #include <fstream> using namespace std; struct computerspec { int ram; int hdisk; }compuspec; int main() { char ch; …

Member Avatar for Narue
0
159
Member Avatar for Tlhokomelo

>My e-mail add is:tlhokomelo@webmail.co.za We don't care because we're not going to be emailing you anything. >but I can not afford to buy books on the subject Somehow, I doubt that unless you can't afford to [url=http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html]download a file[/url]. >Or tell me of a site I can get a lot …

Member Avatar for Narue
0
145
Member Avatar for silicon

>Is there a way that I can a more precise time so that I can get a time for every method The most precise method is use of a profiler program or a framework written using some platform or compiler specific function. If you want to use clock_t and clock, …

Member Avatar for Narue
0
117
Member Avatar for MrNiceGuy82

How about posting a compilable example? Like, with your header includes and driver and the complete function so we can do more than just guess?

Member Avatar for Narue
0
2K
Member Avatar for rharvison

>Any ideas on coding this. Yes, plenty. However, what [B]I[/B] think doesn't matter since it's [B]your[/B] program. What did you come up with before posting here?

Member Avatar for rharvison
0
150
Member Avatar for AhmedHan

>Can you please help me on calling interrupts in that standard? Didn't you already ask that question, or was it someone else? >By I think, one of the h files can be used for this purpose. windows.h, and you have to implement the functionality yourself: [code] #include <windows.h> void gotoxy …

Member Avatar for Dave Sinkula
0
4K
Member Avatar for jaeSun
Member Avatar for jaeSun
0
469
Member Avatar for mdbrock7
Member Avatar for JoBe
Member Avatar for JoBe
0
187
Member Avatar for Daywalker46410
Member Avatar for steosaur(oWn)

push_back requires that you pass an existing object as the argument: [code] vector<int> v; int x; cin>> x; v.push_back ( x ); [/code] You solution is to use a loop: [code] while ( cin>> x ) v.push_back ( x ); [/code]

Member Avatar for Narue
0
777
Member Avatar for kittie

Change this: [code] int numb, tot, count, sum; [/code] to this: [code] int numb, tot, count, sum = 0; [/code] sum was uninitialized for the first run, but after the first run you set it to 0, so the second and third runs work properly.

Member Avatar for kittie
0
174
Member Avatar for silicon

>1. Explain why the following program is illegal in standard C/C++. It's illegal for more reasons than your instructor probably knows. ;) First, cout is used without including <iostream> and qualifying for the std namespace. Second, main doesn't return void, it returns int. Third, variables can only be used in …

Member Avatar for silicon
0
181
Member Avatar for kparnell

What have you tried? Prove that you've made [b]some[/b] sort of attempt or you won't get much help.

Member Avatar for eagleeye
0
136
Member Avatar for Tetsu

>"I'm going to kill your computer if you dont enter the right password!!!" Uh huh. >main(); //go to main to do until success It's illegal to call main recursively in C++. >teach me how to only let the user have 34 tries before it close [code] // Pseudo-C++ int n …

Member Avatar for Tetsu
0
154
Member Avatar for bobr_1013

You need to define an operator>> that looks for an object of your enum: [code] #include <iostream> #include <stdexcept> using namespace std; enum X { A, B, C }; istream& operator>> ( istream& in, X& x ) { int val; if ( in>> val ) { switch ( val ) …

Member Avatar for Narue
0
8K

The End.