6,741 Posted Topics

Member Avatar for rt.arti

[B]>Kindly let me know of alternatives of how I could solve this problem.[/B] You're not actually appending to the file, you're appending to lines in the file, which amounts to inserting into the file. Unless you're using a system with record oriented files, your two best options are probably the …

Member Avatar for uskok
0
146
Member Avatar for Mattpd

[B]>I am not certain where to start.[/B] Then you should consider switching your major. "I don't know where to start" is equivalent to "I'm not cut out for programming". [B]>1. Write a C program that only lists all files in the current >directory and all files in subsequent sub directories.[/B] …

Member Avatar for Trad
0
206
Member Avatar for thinkersgroup
Member Avatar for pecet

[B]>1. Line #8 works (at least my compiler doesn't comply), but line #12 is not allowed. Why?[/B] Because the types are incompatible. It's legal to add a const qualifier as such: [code] int *p = 0; const int *q; q = p; // Okay [/code] Note that p and q …

Member Avatar for pecet
0
165
Member Avatar for jonsca

[B]>so we'll deal with 99 useless posts so we don't lose that 1 good one.[/B] The mods can clean up any messes. I've been on forums where threads were automatically closed after thirty days, and it was a somewhat annoying feature. Just because something sounds good in theory doesn't mean …

Member Avatar for Narue
1
134
Member Avatar for candoc

[B]>Is there a way[/B] Yup, there sure is. It's even easier than looking for tokens because you only need to keep a character count (and look for the end of the string, but that goes without saying).

Member Avatar for jephthah
0
88
Member Avatar for merse

[B]>which one is necessary to overload if i would like to make -x understanable for the compiler?[/B] The negation operator is a single argument member function: [code] class foo { public: // Overload negation foo operator- ( const foo& obj ); }; [/code] [B]>If yes, >than the compiler makes double …

Member Avatar for jonsca
0
117
Member Avatar for restrictment

[code] std::string name; // Get the name... std::ifstream in ( ( name + ".txt" ).c_str() ); [/code]

Member Avatar for Narue
0
106
Member Avatar for merse

I wouldn't bother worrying too much about speed unless you can prove that your code is slow enough to justify optimizing.

Member Avatar for merse
0
170
Member Avatar for Clockowl

[B]>//We want to compare Foo::x here, not the pointers. >bool result = a > b;[/B] That's a very bad idea (even if it doesn't work). You're trying to change the established behavior of an existing type, which could have unexpected effects elsewhere (like when you want to start working with …

Member Avatar for Narue
0
177
Member Avatar for merse

[B]>I cannot find on the web.[/B] You didn't look very hard, did you? [URL="http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html"]This[/URL] is the first hit from google that I got using keywords from your thread title.

Member Avatar for Narue
0
91
Member Avatar for merse

[B]>Therfore the previous one is more preferable?[/B] Passing objects by const reference is preferable because it's pretty much always more efficient than passing by value. The reference generally takes up less memory than an object instance, and the cost of a copy constructor call is avoided.

Member Avatar for Narue
0
115
Member Avatar for merse
Member Avatar for merse
0
104
Member Avatar for tak9

[B]>ok so would it look like this for each cout statment? [/B] Do you even own a book on C++? You're making mistakes that would cause a 1st day beginner to blush in embarrassment. [B]>im not sure how to show how many stars should be given to each range [/B] …

Member Avatar for Nick Evan
0
161
Member Avatar for samweb$

[B]>Below is the block of code for your reference.[/B] Are you using a custom allocator?

Member Avatar for samweb$
0
90
Member Avatar for Stefano Mtangoo

[B]>I don't want to know each and everything in C++[/B] Good. That's probably an impossible goal anyway. [B]>I mean what it takes to be a best C++ expert?[/B] Practice and a constant desire to improve. If you have the latter, you'll find resources to learn from. For example, nobody told …

Member Avatar for mrnutty
0
354
Member Avatar for kavourdoukos

[B]>Sry i was trying to quote from this answer and i accidentally gave -1 at the answer.[/B] I fixed it for you. Now it's back at 0. :) [B]>Can u write the de-allocation of memory in 1 in code pls??[/B] [code] // Allocate T **p = new T*[ROWS]; for ( …

Member Avatar for kavourdoukos
0
86
Member Avatar for Iam3R

[B]>Now the question is how the Assember was implemented, i mean which language?[/B] Any compiler can be written in a suitable existing language. The first assembler was probably hand compiled as machine code. Then the second assembler could be written in assembly language and compiled using the first assembler. [B]>how …

Member Avatar for Iam3R
0
96
Member Avatar for llemes4011

[B]>Is storing the object's pointer, and dereferencing it to access >methods/field, faster than storing it as a normal object, and >calling the method/accessing the fields normally?[/B] No. If anything, pointers are slower due to the extra step of chasing the pointer. Member access is the same either way, once you …

Member Avatar for Narue
0
165
Member Avatar for bj35man

[B]>can I restore my data back?[/B] There are a number of software packages that "undelete" deleted files, but I wouldn't expect too much from them if I were you. In my experience they're hit or miss (with a tendency toward miss). [i]Real[/i] restoration is a very expensive manual process, so …

Member Avatar for bj35man
0
93
Member Avatar for UberJoker

MyChar is an array of char. a[i] is a single char. The two types are completely incompatible. [ICODE]MyChar[i] = a[i][/ICODE] would work. At least until i gets incremented past 1, then you're accessing a out of bounds.

Member Avatar for UberJoker
-1
1K
Member Avatar for simplyscottif

[B]>here is what i have so far (it won't compile)[/B] So what do you want us to do? Finish it up for you, tie it up with a pretty little bow, and send it to your teacher with your name on it? Why don't you try posting what errors you're …

Member Avatar for Murtan
0
228
Member Avatar for Darkipod

Why don't you search the post archives? We get this request regularly, and the questions are almost always identical.

Member Avatar for BestJewSinceJC
0
111
Member Avatar for lonprog

[B]>Does anyone have code out there on how to do this?[/B] Correct me if I'm wrong, but isn't the point of the project for [i]you[/i] to write the code? Assuming this is homework, you don't really learn anything by stealing another programmer's code and palming it off as your own.

Member Avatar for mrnutty
0
120
Member Avatar for CppBuilder2006

GetData and GetSize are called on objects that are qualified as const. In such a case the compiler has to assume that both of those functions modify the state of the object, so it disallows the call. You can fix it by qualifying the two member functions as const since …

Member Avatar for CppBuilder2006
0
84
Member Avatar for merse

[B]>I need to include some standard libraries. >But I dont want to overload them, what is the solution? >I have to use #ifdef ?[/B] Standard headers should manage this kind of thing. Just include the headers and don't worry about it unless you discover a problem down the road. [B]>If …

Member Avatar for Narue
0
149
Member Avatar for punchinello

[B]>Prefer a plain int over a short int or a long int.[/B] int (as opposed to short int or long int) has traditionally been the "natural" integer size for the platform. Using this "natural" integer size gives more leeway for optimization at both the implementation level and the platform level. …

Member Avatar for Narue
0
80
Member Avatar for srisan
Member Avatar for revenge2

[B]>any suggestions?[/B] Yes. Be more specific. I mean, if you can't find the row and then overwrite it with strcpy (or something similar, maybe sprintf), you must have a different problem than the one implied by your question.

Member Avatar for Narue
0
105
Member Avatar for xonxon

If you want an algorithm, I'd recommend looking for patterns in the traversal results. For example, the root is the first hit in preorder and the last hit in postorder. You can go from left to right in preorder and find the left parent vine (C, B, A in your …

Member Avatar for mrnutty
0
142
Member Avatar for BobRoss
Re: File

The >> operator is default delimited by whitespace. If your strings need to contain whitespace, use getline instead. FYI: [B]>ifstream plainText(inputPath.c_str()); >ofstream cipherText(outputPath.c_str());[/B] This won't do jack because inputPath and outputPath are presently empty strings. You need to open the file after figuring out what the path is. :icon_rolleyes: [B]>while …

Member Avatar for jonsca
0
111
Member Avatar for PopnFresh
Member Avatar for merse

[B]>However if I define a user defined object, I must initialize it like: >myclass myobj();[/B] Actually, that example is wrong. Due to some grammar issues, myobj in your example is actually a function declaration, not an object of myclass. When creating objects using the default constructor, you [I]don't[/I] include a …

Member Avatar for mrnutty
0
101
Member Avatar for calypso&noname

You want to compare with the current index, not counter. The value of counter is the number of legit values in the array. Using it as an index in an array that was not completely populated is extremely likely to be undefined behavior. This is the algorithm: [code] int min …

Member Avatar for calypso&noname
0
124
Member Avatar for Mclovin1234

[B]>I have no clue on how to do this please help thank you [/B] You'd better learn quickly how to deal with this situation without running to someone else for hand holding. The majority of the time, a programmer has no clue how to do something. That's why it's such …

Member Avatar for mrnutty
0
98
Member Avatar for kgomes

[B]>It should be considered valid, but it's not.[/B] Direct comparison of floating-point values is risky because some values might not be exact, and the comparison will produce an unexpected result. You should take care to use a fudge factor when doing this kind of comparison: [code] #include <stdio.h> #include <stdlib.h> …

Member Avatar for Narue
0
97
Member Avatar for dark1806

[B]>if(strcmp(caracter,argv[1]))[/B] strcmp returns a comparison, not a boolean. In other words, 0 is a match and non-zero is a failure to match. Thus, your if statement is reversed. You print the line when it doesn't match argv[1]. This should work better: [code] if ( strcmp ( caracter, argv[1] ) == …

Member Avatar for Narue
0
91
Member Avatar for ababhijit das
Member Avatar for Narue
0
101
Member Avatar for ssheck1034

[B]>If not, guide me toward proper etiquette.[/B] Code is nice, but if you're getting an error, it's helpful to post that as well.

Member Avatar for Narue
1
66
Member Avatar for tennisshoes

[B]>-How can i make the array any size, so it can quit on the 2nd >number entered or the 27th number entered?[/B] That really has nothing to do with the array size. The histogram array only has ten elements, and each element is a count of the numbers that fit …

Member Avatar for Narue
0
450
Member Avatar for daviddoria

[B]>Think about the relationship described by inheritance, >and why what you're doing isn't possible[/B] And yet it [i]is[/i] possible. What the OP wants to do is called downcasting. It's not recommended for the obvious reasons, but it's a feature that C++ supports using dynamic_cast because it's sometimes necessary: [code] #include …

Member Avatar for daviddoria
0
5K
Member Avatar for seaders

>I can't see any other way to pass the ... arguments, other than >through the "va_list args" and va_start lines, am I wrong in thinking that Nope, you're right on track.

Member Avatar for seaders
0
933
Member Avatar for avitar

[B]>Is C++ the easiest language ever?[/B] No, it's one of the hardest. [B]>anybody know how to help?[/B] Nope. Your question is about as close to incoherent as they get. Can you try to make more sense?

Member Avatar for Narue
0
77
Member Avatar for gehring

[B]>myarray.clear(); //Doesnt deallocate the memory[/B] Correct. Clearing the array only changes the size. [B]>myarray.reserve(0); //Doesnt deallocate memory[/B] Correct. Reserving space only causes reallocation if the new size is greater than the current capacity. [B]>myarray.swap(myarray);//Doesnt deallocate memory[/B] This isn't required to shrink-wrap the capacity. You [i]might[/i] have better luck with a …

Member Avatar for gehring
0
331
Member Avatar for gehring

[B]>Hmm, That's very odd![/B] Not especially, though it can be surprising. This is the underlying problem: [code] #include <iostream> #define UNICODE #include <windows.h> int main() { TCHAR *s = L"test"; std::cout<< s <<'\n'; } [/code] My crystal ball says the UNICODE macro is defined, which causes CString to resolve to …

Member Avatar for Narue
0
817
Member Avatar for noey699

Just use a pointer to a function for the callback: [code] #include <iostream> class foo { int _i; int _limit; void (*_action)(); public: foo ( int limit, void (*action)() ) : _i ( 0 ), _limit ( limit ), _action ( action ) {} bool done(); }; bool foo::done() { …

Member Avatar for noey699
0
96
Member Avatar for saharh89

[B]>I don't understand how to add a char * member to points to a string.[/B] Look at the Cd class and do the same thing with your child class. The Cd class has char* members as well, so it's not like you don't have an example to work from. :icon_rolleyes:

Member Avatar for Narue
0
166
Member Avatar for samsons17

[B]>Use a database.[/B] Use your brain. This guy is clearly a beginner, and you want him to struggle with a database API on top of basic C++ for a trivial problem? [B]>I've tried so hard,but so far i still cant figure out what is the actual way to do this....[/B] …

Member Avatar for samsons17
0
100
Member Avatar for hajiakhundov

Mixing C++/CLI and standard C++ can be troublesome. Try sticking to one or the other unless you have good reason not to: [code] label2->Text = Convert::ToString ( a ); [/code]

Member Avatar for hajiakhundov
0
2K
Member Avatar for Sky Diploma

You're working with uninitialized pointers. Pass the matrices as references: [code] void generate(int**&, int, int); void fill(int**&, int, int); int** compute(int**& ,int**&, int, int, int, int); void dellocate(int**& val, int x, int y); void display(int**& val, int x, int y); [/code] Match that in the definitions, and that's the only …

Member Avatar for Sky Diploma
0
155

The End.