537 Posted Topics

Member Avatar for OliverW

[quote][code]vector<MyClass> MyVector; MyVector.push_back(MyClass(Param1, Param2, Parm3, Param4));[/code] As I understand this would involve creating two instances of the object and copying one to the other. Is that correct?[/quote] As I see it, you are creating one instance of 'myclass' which pushed into the vector. [quote] Would it run quicker if I …

Member Avatar for Clinton Portis
2
132
Member Avatar for alnea
Member Avatar for Amreen
Member Avatar for zobadof
0
57
Member Avatar for xman13157
Member Avatar for EliteApple

You appear to be lost and overwhelmed held captive in a class that probably has no relevance whatsoever to your degree major. What you need is a strategy to tackle this seemingly overwhelming task. If you look at this thing in it's entirety, yes.. it does look like some intense …

Member Avatar for EliteApple
0
576
Member Avatar for simonfoley

Why ruin a good thing you already got goin'? [CODE] //this gets(employee[counter].name); //should be this cin >> employee[counter].name;[/CODE] I am really not sure where you got "gets()" from.. I think it's a C function... and if I'm not mistaken it's use can be somewhat dangerous. In my opinion, it is …

Member Avatar for simonfoley
0
234
Member Avatar for jennwenn25

would this be anything close to what you need...? [CODE] void TicTacToe::postMove(int row, int col, char value) { theboard[row][col] = value; showBoard(); }[/CODE]

Member Avatar for Clinton Portis
0
217
Member Avatar for PDB1982

I found [URL="http://msdn.microsoft.com/en-us/library/ty2ax9z9(VS.80).aspx"]this[/URL] article at msdn: [quote] The multiplicative operators take operands of arithmetic types. [COLOR="Red"]The modulus operator (%) has a stricter requirement in that its operands must be of integral type.[/COLOR] (To get the remainder of a floating-point division, use the run-time function, fmod.) The conversions covered in Arithmetic …

Member Avatar for DavidRead
0
120
Member Avatar for p3rsia

[CODE] //Write a program that creates an array dynamically whose pointer must not change const int* array = new int[size]; //initialize the array to random values between 0 and n (inclusive) using rand () for(int i=0; i<size; i++) array[i] = rand()%(n+1); //then pass the array to a function that takes …

Member Avatar for Clinton Portis
0
163
Member Avatar for nerdthon123
Re: Help

This one is pretty decent: [url]http://www.codeblocks.org/[/url] Not as easy as it used to be.. you could easily start a 'project' as opposed to a 'c++ source' which will mess things up. The debugger is kinda wack. Also, it forces you to save work you haven't even created yet. If you …

Member Avatar for jonsca
0
127
Member Avatar for Puddles

After briefly looking at your code.. maybe all it needs is just a space in between commands: [CODE] //this strcpy(str, "taskkill /f /im"); //might work if it was like this: strcpy(str, " taskkill /f /im");[/CODE]

Member Avatar for Puddles
0
236
Member Avatar for zobadof

Move on through your C++ at a rate at which you understand the material (for the most part) and then begin to tackle the next concept.

Member Avatar for zobadof
0
53
Member Avatar for kele1

I would be more than happy to help you.. however, I cannot read a bit of that antiquated C code that you have posted in this C++ forum...

Member Avatar for Clinton Portis
-1
97
Member Avatar for trcartmill

Here is recent help given to one of your classmates: [url]http://www.daniweb.com/forums/post1070744.html#post1070744[/url]

Member Avatar for Clinton Portis
0
107
Member Avatar for new programer

[quote]I'm trying to do a concatenation function I do not want to you use the strings property where we can add strings, I need to add two strings and save them in one string without the use of addition "+"[/quote] Instead of trying to decipher your code, I will offer …

Member Avatar for new programer
0
156
Member Avatar for halluc1nati0n

[quote]I have to read 16 bytes using the low-level function call read() (in C). After I read the first 16 bytes, the next time I need to read from the same file, I'll only have to read it from until the point it was read before.. [/quote] Since you only …

Member Avatar for halluc1nati0n
1
309
Member Avatar for keyzzz_it

You seem to have mentioned that you have attepted to make some sort of effort at seeking a solution to the problem. I'm sure myself and others would be highly interested in seeing what you have come up with thus far; thereby seperating yourself from the masses of "please do …

Member Avatar for xavier666
0
178
Member Avatar for sperrytx

You seem interested in reading in a file until you reach a delimeting comma. In this case, I recommend use of [URL="http://www.cplusplus.com/reference/string/getline/"]getline()[/URL]. There are a few different getline() functions floating around in the c++ world. The one we are using (and most popular in file i/o) is derived from the …

Member Avatar for Clinton Portis
0
292
Member Avatar for guccitan88

[quote]I have everything I need in the code except the "between 100 and 1000." [/quote] [CODE] //Line #28 should be this: popList[i] = rand( ) % 901 + 100 ; [/CODE]

Member Avatar for guccitan88
0
118
Member Avatar for bonotevo

I will offer few improvements to your code and propose a possible pseudo-coded solution to your initial question. Firstly, reading in an entire file character at a time is inefficient should be avoided. There may be some situations where this approach may be warranted; however, I believe that this isn't …

Member Avatar for Dave Sinkula
0
302
Member Avatar for Bladtman242

I think the problem is here... [CODE]for (int i=-1;ip!=" ";[COLOR="Red"]i--[/COLOR])[/CODE] Since you are using the 'end' flag in seekg(), all offset is relevent to the end of the file.. therefore, you should increment your way from the end of the file, stepping your way backwards into the text file. You …

Member Avatar for Bladtman242
0
629
Member Avatar for saharh89

What part of the assignment is giving you difficulty.. ? After breifly looking at your attachment, it seems that the assignment is already well outlined for you.. all you have to do is create a simple child class with one additional attribute that will identify the primary work on the …

Member Avatar for Narue
0
166
Member Avatar for hajiakhundov

Looks like ye' need to perform a good ol' [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045689663&id=1043284385"]int-to-string conversion[/URL]. Today we'll be creating an 'ostringstream' object derived from the <sstream> library in order to facilitate our int-to-string needs: [CODE] #include<sstream> #include<string> #include<iostream> using namespace std; int main() { ostringstream int_to_str; string temp; int a = 0; cout << …

Member Avatar for hajiakhundov
0
2K
Member Avatar for norbert90
Member Avatar for Clinton Portis
-5
93
Member Avatar for gehring

What you are asking for can be a very useful data structure... if created dynamically can have about the same performance as a vector and might even be more efficient (a vector might allocate more memory than what you actually need based on the number of push_back() opearations) In either …

Member Avatar for Clinton Portis
0
835
Member Avatar for Clinton Portis

Unfortunately in c++, there is really no good way go locate lines in your file without reading the entire file 'character at a time.' So, if you [I]have[/I] to read only a single line from a file, we know we are at some point going to have to be inefficient... …

Member Avatar for Clinton Portis
2
2K
Member Avatar for nunchuckie

try this string parsing algorithm to split your line up into individual strings: [CODE] #include<string> #include<vector> int prev = 0; int curr = 0; string temp; string line = "The man is 67 years old and driving an Oldsmobile Rocket 88"; vector<string> vstring; do{ prev = curr; curr = line.find(' …

Member Avatar for Clinton Portis
0
115
Member Avatar for Tex09

Here is documentation for[URL="http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html"] getcwd():[/URL]

Member Avatar for Tex09
0
203
Member Avatar for nunchuckie

Here is one possible way: [CODE=c++] int i = 0; int line = 0; int number = 0; char c = '\0'; string temp; //Make sure your file is opened in binary mode when manipulating file pointers infile.open("C:\\Documents\\test.txt", ifstream::binary); cout << "Enter line number to read from file: "; cin …

Member Avatar for nunchuckie
0
137
Member Avatar for tomtetlaw

right now all that I see that might cause stack overflow might be this.. [CODE] std::vector<BaseEntity> BaseEntity::sm_vEntities = std::vector<BaseEntity>(100000); [/CODE]

Member Avatar for tomtetlaw
0
240
Member Avatar for lovely ari
Member Avatar for adi.shoukat

I imagine this would require some sort of DLL injection.. where applications would send messages back to your program about their status, specifically if they have the input focus.. window is active or minimized. I believe the last chapter of "Advanced Windows" by Jeffrey Richter covers dll injection, reading and …

Member Avatar for Clinton Portis
0
97
Member Avatar for Phil++

I find the concept of polymorphism (inheritance) to be a quite interesting topic.. although I am by no means an expert in this (I just do enough of this to get by) I believe it is a powerful OOP concept and in my opinion, is probably the main construct that …

Member Avatar for mrnutty
0
91
Member Avatar for mikesr

Here is just one possible solution to the first part of the problem, there are probably much better loop(s) you can come up with but I am lazy. It is pretty much self explanitory. You can give the second part of your problem a try. Let me know if you …

Member Avatar for mikesr
0
286
Member Avatar for Darth Vader

[quote]Important to know is that this file also only can consist of one line.[/quote] [quote] 3 lines in a file:[/quote] Do you people not speak english as a native language... or enjoy confusing the rest of the world. Here is an important excerpt from, [URL="http://catb.org/~esr/faqs/smart-questions.html"]"How to ask questions the smart …

Member Avatar for Darth Vader
0
3K
Member Avatar for redback93

People always ask, "Why do you always have to initialize your variables?" This is why: [CODE] //Here you create something. It is never initialized; therefore probably contains some sort of value.. what exactly it contains, we don't know. long double points;[/CODE] So when you start using this varible for accumulation, …

Member Avatar for redback93
0
104
Member Avatar for qk00001

Do you mean like this? [CODE] str1 += str2; str1 += str3; str1 += str4; str1 += str5; cout << str1; [/CODE]

Member Avatar for qk00001
0
112
Member Avatar for Phil++
Member Avatar for mrnutty
0
152
Member Avatar for LisaJane

The recommended scheme for File I/O is to create an fstream object, attempt to open a file, perform error checking, and load the file. The code in question is performing error checking to see if the file was actually opened. It is quite possible that the file may have been …

Member Avatar for xaveri
0
5K
Member Avatar for jacline

[quote] How can I check whether my code has memory leak or not? [/quote] [LIST] [*]objects allocated memory using 'new' must be deleted. [*]anytime you access an array out of bounds [*]anytime you try to dereferrence a NULL pointer. [*]anytime you leave a dangling pointer, for example: [/LIST] [CODE] int* …

Member Avatar for jacline
0
106
Member Avatar for Jamesinuk

[CODE] //This char * DecData = new char (stringlen+1); //Should be this: char* DecData = new char[(stringlen+1)]; //This int * NewData = new int (strlen(Data)); //Should be this: int* NewData = new int[(strlen(Data))]; [/CODE]

Member Avatar for Jamesinuk
0
94
Member Avatar for nhatphongtran

[quote] But how do I do this without knowing which name that object got?[/quote] Give ye' who is nameless a name: [CODE] point* mypoint = new Point(Point::SPHERE, 300.0f, i); out.add_primitive(obj, mypoint); [/CODE]

Member Avatar for Clinton Portis
0
82
Member Avatar for Silvershaft
Member Avatar for samsons17

[quote]How could i make the program that could limit the input integer the user try to enter[/quote] [CODE] int x=0; //Force user compliance..!!! do{ cout << "Enter a number between 1 and 20: "; cin >> x; if(x<1 || x>20) { cout "\aNumber out of range, try again!"; } }while(x<1 …

Member Avatar for jonsca
0
152
Member Avatar for Doughnuts
Re: Sigh

I'm not sure right off hand what is going on, but here is a couple of things that I like to try when the unexpected starts to happen in my file i/o operations: [LIST] [*]try opening your file in binary mode [*]it seems like you might be using your ofstream …

Member Avatar for bamcclur
1
113
Member Avatar for Frap

These variables are uninitialized and could contain any value that happened to reside in their memory location at the time of their creation: [CODE] //These could be any value..! we don't know what they are..! int x,factorial; [/CODE] How can x equal 1 and 0 at the same time? [CODE] …

Member Avatar for donaldw
0
100
Member Avatar for itzaaron

Although I am not an inheritance expert, I have a feeling your inputInfo() outputInfo() functions of your [U]parent class[/U] need to be labeled 'virtual' because they are overridden in the child class.

Member Avatar for GrubSchumi
0
87
Member Avatar for astroshark

try making this small adjustment to your 'while' loop condition: [CODE] while((score < 0 || score > 100) && (score != -999)); [/CODE]

Member Avatar for astroshark
0
96
Member Avatar for PDB1982

By doing this, you have established a direct relationship between the two arrays: [CODE] //We can assume that 'votes[3]' corrosponds to 'candidates[3]', for example. if ( inFile >> candidates[i] >> votes[i] ) [/CODE] So all you really need to do is extract the largest value from the votes[] array: [CODE] …

Member Avatar for Clinton Portis
0
134
Member Avatar for T-Dogg3030

[CODE] //Loads the array with ascii values ranging from 65 to 122 ('A' thru 'z') static_cast<char>(array[i]) = rand()%58 + 'A';[/CODE]

Member Avatar for mrnutty
0
304

The End.