6,741 Posted Topics
Re: >then how can i force the user to enter the righr information I'll assume you mean forcing them to choose one of the selected options. ;) You do that with validation. After the choice is entered, you make sure that it matches one of the options and if it doesn't, … | |
Re: No, associative containers don't support setting the capacity without explicitly adding a range of items. >I have to map this in shared memory That's not an issue. The map object itself has a fixed size because it uses dynamic memory by default for the items. Provided you share the structure … | |
Re: So...basically you're writing a heap, right? >The part I am facing trouble with is doing the actual swap, as 'parent' is only a pointer to the node's parent. Are you swapping data or doing a physical swap? If you're swapping data, I don't see what the problem is. If you're … | |
Re: >It's pretty simple first create a binary tree, then read the input and insert >each element in appropriate place in teh tree, then read it back in postfix notation. Brilliant. :) ![]() | |
Re: >Without changing the main function modify the following code so that the o/p is Okay, done. Show me yours and I'll show you mine. | |
Re: >return ptr[0]=ptr[length-1]; You always return here, so the two lines after this can never run. >while(*ptr!='\0') If you have a loop in a simple recursive function, it's probably wrong. Remember that you're using the recursion to hit each element in the array, so that loop should be changed to an … | |
Re: This is a special operation that can't easily be done using just the basic queue operations. So you should make it a non-member friend function and sort the internal storage structure. | |
Re: Ugh. If you don't know why that's ugh, you shouldn't be using it. Try this instead: [code] #include <iostream> int main() { std::cout<<"Hello, world!\n"; } [/code] | |
Re: >when it is necessary to include a return statemnt in one's code When you're returning from any function whose return type is not void. >what is the difference between recursion and iteration? At what level? At the highest level, there's no difference. Go a bit lower and recursion is just … | |
Re: >This was sent to me today... You fall for a lot of scams and hoaxes, don't you? | |
Re: >that's c not c++ sprintf is C++ too. >do u know anyother sol. in c++ Yes, use the hex manipulator with either cout or a string stream. Alternatively, you can do the conversion manually, but since that's available in C as well, I guess it doesn't count as C++. :icon_rolleyes: | |
Re: >but when i tried 2 open it , it doesn't work. You're reading from a binary oriented file stream but writing to a text oriented file stream. Most likely you want to open the output stream as binary also. And please don't use chatty abbreviations. We have a rule against … | |
Re: >>>fflush (0); >That is non-standard No, it's well defined by the standard. If the argument is a null pointer, all open output streams are flushed. | |
Re: >I just have a question is the book C++ Programming Primer By D.S. Malik a book worth getting? You can get it on Amazon for less than $5, so it's not something you have to think too hard about. If it's a bad book, not much is lost. If it's … | |
Re: [url]http://www.daniweb.com/techtalkforums/thread78223.html[/url] | |
Re: >I just was wondering why the array its self are a pointer to the first element? Because it was a design decision by the language creator. >and what is the difference between an array and a pointer? An array is a collection of objects, and a pointer is a variable … | |
Re: It hides the content of posts (which you can see by clicking a link), but not the fact that a post was made. I don't believe it blocks PMs or rep. All in all, I think the ignore feature is worthless. You're basically hiding posts when if you really have … | |
Re: You're using strings, why not use vectors too? Much easier. | |
Re: It depends on what you're looking for. Perhaps the post shown in the tooltip could show the first post based on your thread display options? If you use linear with oldest first, it would show the first post, and linear with newest first would show the most recent. I don't … | |
Re: The default because I type code tags manually and I'm too lazy to add the language. And yes, I'd prefer a box as it clearly separates two different code blocks without having to add text between them. Why do you ask? | |
Re: A good entry level job will give you a lot of exposure to existing code and the people who wrote it. That way you can read code, maintain code, and learn from more experienced programmers. A good entry level job will also put you in a position to watch and … | |
Re: >so, if you will check if the input is a number or not, what is the appropriate function to use??? You're using formatted input, so you just need to check the error state of the stream object: [code] if( !( cin>> temp2 ) ) { cout << "not a number … | |
Re: >Why should it run Perfect under windows?? Pure luck. >Why the ruckuss in Linux? The problem is here: [code] strcpy([COLOR="Red"]str1[/COLOR],cat[b].lname);//flagged strcpy([COLOR="Red"]str2[/COLOR],cat[b].fname); strcpy([COLOR="Red"]str3[/COLOR],cat[b].title); [/code] str1, str2, and str3 don't point to anywhere predictable, and certainly not to arrays (that you own) large enough to hold the strings your copying into them. … | |
Re: You need to know how long the string is, and how wide the available field space is. Then take the difference of that and if it's greater than 0, prepend that number of spaces onto the string: [code] #include <iostream> #include <iomanip> #include <string> std::string right_justify ( const std::string& s, … | |
Re: >my question is i want help to develop a pseudocode for this program before i can compile it That's not a question, it's begging for code. It doesn't matter if the code is pseudocode or C code. It's still code that represents a solution that [b]you[/b] are supposed to figure … | |
Re: What an incredibly biased test. It's immediately obvious what kind of "Emotional IQ" they're trying to force you to have. :icon_rolleyes: | |
I've noticed a need for this both as a mortal and as a mod. If I could set up a list of "people to watch" that would show me the same information as the currently active users list except with only those people, that would be stellar! :) On a … | |
Re: >num[a] = num[a] = '0'; = is not the same as -. One is assignment, the other is subtraction. This is the line you want that will give you the correct sum: [code] num[a] = num[a] [B][I][COLOR="Red"]-[/COLOR][/I][/B] '0'; [/code] | |
Re: >DataFile.open(fileName, ios::out | ios::app); [code] DataFile.open(fileName.c_str(), ios::out | ios::app); [/code] The open member function takes a C-style string. | |
Re: >Is there anyway i can learn system programming in C? Probably. >What site would you recommend?? I wouldn't. I would recommend a few books depending on the OS you plan to work with. | |
Re: 4'11", my husband is 6'0". | |
Re: >Does it have something to do with how I got scores? It probably has something to do with returning an int from a function that's defined to return a string... Also, your function probably doesn't do what you want. Can you describe what you think it should be doing? | |
Re: >This will work in C++ wht abt c? No, it won't work in either because you can't call a function at global scope. It also fails to meet the requirements because you try to use printf. :icon_rolleyes: >HOW sizeof() implemented in C means Sourrce code? You can't do it portably. … | |
[B][U]Before You Ask[/U][/B] [list=1] [*][B]Engage your brain![/B] We understand that running into a problem can turn off the rational centers of the brain, but please sit back and think for a bit about your problem before running off to find help. All too often a little common sense is all … | |
Re: >i just want to know how to compare a string to null You don't. NULL is a null pointer and a string object isn't a pointer. Most likely you want to check for an empty string: [code] if ( x == "" ) [/code] or [code] if ( x.empty() ) … | |
Re: >- use inline functions (new compilers do this implicitly though) The compiler is in a better position to know what functions are best inlined. An explicit inline keyword strikes me as akin to the register keyword in premature optimization. >- use registers. Speaking of the register keyword, don't waste your … | |
Re: If you actually formatted your code intelligently, this error would be obvious. Here's the same code with better formatting. I've pointed out the error in red: [code] template <class Type> int isPalindrome (Type * word) { stackType <Type> mystack; int i=0,count=0; while(word[i]!=NULL) { count++; i++; } int half=count/2; for(int j=0;j<half;j++) … | |
Re: That's either very old, or very uncreative. Because I've seen it before. ;) | |
Re: >There is some syntax of cin that allowes us to ignore the \ns.. Isn't it? You're probably thinking of the ws manipulator, but it discards [I]all[/I] whitespace. If you want more control, you have to write your own manipulator: [code] class scan { public: scan ( const char *init ): … | |
Re: Perhaps you should ask your question with a new thread in the VB forum instead of resurrecting a [B]four year old[/B] C++ thread. kthnxbye. | |
Re: I imagine the problem was designed to force you to use a recursive solution. That's really the only way to loop without using a loop. | |
Re: >cuz i did it in the most retarded way ever Not really. You're on the right path. You need to split up the data entry and printing parts. They can both be written using a simple nested loop for a two dimensional array: [code] // Read the student's grades for … | |
Re: >What is the size of an activation record for the function f()? It depends on the compiler and there's really no reason for you to care in client code. >How did you find out? Experience and knowledge of the C standard. | |
Re: I don't mind striking the point home, but if this turns into a whine thread, I'll either have to unsticky it and start my own, or get out the mod stick. | |
![]() | Re: I'm constantly amazed how people use an ancient compiler with an obsolete graphics library and expect it to work seamlessly with the latest operating system... |
Re: So what's your question? Posting nothing but a homework problem suggests that you want us to do it for you, which isn't going to happen. We require effort on your part before we'll offer any help. | |
Re: >that's the real art of programming, isn't it? Not really. The real art of programming is solving the problem without creating an unruly mess. You can learn the names and memorize the code for a thousand algorithms and still be completely incompetent. >I guess it comes with experience, but most … | |
Re: >I did the changes but still having issues. It would be nice if you told us what those issues were. :icon_rolleyes: >cout endl; That won't compile. You probably meant [inlinecode]cout<<endl;[/inlinecode]. >grade= ((10- (grade/10)) + 64); grade doesn't have a predictable value but you use it in an expression... |
The End.