6,741 Posted Topics
Re: >can any one help me with any logic for serialization in C/C++ There's not just one way to do it. How you serialize a structure depends on the type and contents of your structure. But an easy (and verbose) way is to save the contents as a delimited string: [code] … | |
Re: >Do I need to initialize 'word' to a constant size before using it? Yes, otherwise it's an incomplete type that you can't use. >The thing is I don't know how big the string from strtok is going to be >and I will constantly be using 'word' to store different size … | |
Re: Is this a VB question? Maybe you should ask in the VB forum. Thankfully, C++ and VB are [b]not[/b] the same thing. :) | |
Re: >the command prompt shuts down before anything is displayed Actually, everything is displayed just as you intended, but the window closes too fast for you to see that. This is a common problem that can be fixed simply by asking for input before the program terminates: [code] #include <iostream> #include … | |
Re: What have you tried so far? Unless you show us your attempt, we'll assume that you didn't even try to think about it before running here for help. | |
Re: I'm sorry, I tossed out my crystal ball years ago. You'll have to be more specific instead of expecting us to read your mind. As given, your question is ambiguous. | |
Re: Just hang around here. There are armies of noobs with Turbo C/C++ on Windows XP itching to write games. I'm sure someone will post what you want in the next 20 minutes or so, judging from the frequency with which we see people like that. | |
Re: This thread gets my vote for the vaguest question of the month. | |
Re: > 'count' : redefinition; different basic types What compiler and operating system? And are you compiling as C or C++? | |
Re: >what are Reputation Points? A frivolous and pointless feature that nobody cares about. >And how exactly does this system work? If you see a post you like, you can give the poster good rep. This increases that person's reputation by a certain number of points depending on how many points … | |
Re: shaji: Your code is horribly, horribly broken. Before you try to teach C, please learn it first. alajaji: We don't do homework. Show your attempt. | |
Re: Just to clarify, you'll be hard pressed to find a C++ compiler that doesn't have a switch that forces it to compile C. They're also more likely to be up to date than the C only compilers you'll find. | |
Re: >I think Narue wrote it on another forum. I sure hope not. You're looking at a common bug/assumption with the heapsort algorithm. A lot of the time, people writing about heapsort will assume that arrays are 1 based instead of 0 based, which results in an off-by-one error when an … | |
Re: >biggest overheads with goto is having your peers laugh at you. Amen. Of course, I would say that the biggest overhead at first is constantly having to defend your decision to use a goto. Even if you use it intelligently, there are armies of the ignorant waiting to flame you … | |
Re: >but you don't have that many active posters/posts Daniweb is more than just a forum, a fact that Dani has been trying to emphasize with the new design. And forum activity can't be measured with new posts alone. A lot of people lurk but don't post for various reasons. A … | |
Re: >What purpose exactly does scaling / shifting rand values serve? rand gives you a number from 0 to some big value. Sometimes you don't want that. Sometimes you want a number from 0 to 10. But if you might get a number from 0 to 32767, you need to force … | |
Re: >So What Is Everyone's Beef With Aol Anyway???? There has to be a reason? Now, capitalizing every word in a sentence, there's definitely a reason why [b]that[/b] is annoying. | |
Re: >This is what you want ? No, that's not what he wants, but it's exactly what he deserves. Broken code using poor practices so that he'll get a failing grade even if he isn't expelled for cheating. For future reference invisal, we don't do homework for other people because it … | |
Re: That's a subtle error telling you that functions don't nest in C++. But aside from that, your use of whitespace is painfully inconsistent, and you have too many pointless comments. Here is your code corrected, cleaned up, and reorganized to be more transparent, though I haven't run it: [code] // … | |
Re: >Hmm, that's weird. No, it's not only understandable, it's expected. Everybody is a hypersensitive weenie these days. The fall of the human race is entertaining to watch. | |
Re: >cin.ignore(numeric_limits<streamsize>::max(), '\n'); If you're going to use this solution, you need to include <limits> to get access to std::numeric_limits<>. | |
Re: >Does he or she win a free turkey? A life. And he or she can have yours since you're obviously not using it. | |
Re: >To my knowledge with cin you must press enter to assign whatever they typed to a variable. Correct. Input in standard C++ is line oriented, so to read raw input you need to use a system-dependent or compiler-dependent solution. [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048384015&id=1043284392]This[/url] is offers three such solutions, but since you didn't tell … | |
Re: >can someone help?? I think I'm done trying to help you. You seem completely incapable of doing anything on your own. p.s. The next thread you start with this same question will get deleted. | |
Re: Here is the basic idea behind what you're trying to do: [code] // Pseudocode for ( i = first; i != last; i = next ( i ) ) { for ( j = next ( i ); j != last; j = next ( j ) ) { if … | |
Re: Is this C or C++? How is the date originally stored? I assume it's a string, but you need to be more specific about what you need or we'll be of no help to you. | |
Re: Vectors are evil, look up the ArrayList if you want an array that grows as needed. | |
Re: >Can we find the smallest of three integers, without using any of the comparison operators....logic please Can we find out why you're interested in such a silly problem? Logic please. | |
Re: >But this function always prints NO. The only thing that function should print is a compiler error and at least one warning if your compiler is half decent. >Why is it so with float variable It has nothing (or rather, little) to do with your choice of types. 0.7 is … | |
Re: >but still it gives the same dialog box....is there any way to switch it off The way it's supposed to work is that you define NDEBUG and it disables debugging assertions. Will it work in this case? I doubt it, because if there is a hardcoded limit in your memory … | |
Re: >sizeof (int) gives me 4 bytes...is it sufficient to say that my machine is of type 32-bit For your intended purposes, it probably is sufficient. But even if a machine supports 32-bit integers or has a 32-bit address space that doesn't mean it's a 32-bit machine. The term 32-bit machine … | |
Re: >how in blazes does one know if the results of multimapname.find >("Whatevah") will give me access to the correct value (ie, column) I want to check? One doesn't know. The order of duplicates in a multimap is unspecified. | |
Re: Talk about bending over backward to use a linked list when a binary search tree would easily solve the problem. Let's start by figuring out which part of the task is giving you trouble. Do you know what a linked list is? Have you ever written one? Start by inserting … | |
Re: No, malloc returns a null pointer if it fails, just like in C. So you should always test for success like this: [code] p = malloc ( n * sizeof *p ); if ( p == NULL ) { // Handle malloc failure } [/code] Of course, in C++ there's … | |
Re: >A NULL pointer is a pointer that points to address 0 Bad dragon, now you're just confusing people. A null pointer doesn't have to refer to a specific address, and just because 0 is a null pointer constant doesn't mean it points to address 0. | |
Re: >I need to write about a half one page instruction string for one of my C++ programs. Try again, this time in coherent English, please. | |
Re: >how would i feed the processor raw binary in C/C++ ? Use embedded assembly. That's the closest you'll get if you have to ask this question. | |
Re: >I want to know why is it so that, in the Case of C Language there is no >need to include stdio.h Header file. It's a (mis)feature in C89 to provide backward compatibility with K&R C. Don't take advantage of it though, you'll end up causing yourself more problems than … | |
Re: Aside from beeing formatted poorly and riddled with undefined constructs, what is it not doing that you want it to? Posting a vague question and ugly code isn't likely to get you a useful answer, so you need to work with us if you want help solving your problem. | |
Re: >Yes you can Once you realize that it's a stupid trick question, of course. ;) | |
Re: The only difference is asking for an operator too: [code] #include <iostream> using namespace std; int main() { int a, b; char op; cin>> a >> ws >> op >> b; if ( op == '+' ) cout<< a + b <<'\n'; else if ( op == '-' ) cout<< … | |
Re: Don't spam the forums, this isn't a chat room. You're lucky I'm in a good mood or I would have deleted this thread too and had you banned for ridiculously inappropriate behavior. >please tell me what to do You're using an ancient compiler, probably on a Windows XP system. It's … | |
Re: So? C++ doesn't try to stop you from trying to do stupid things. How about instead of asking why you can do something blatantly wrong, DON'T DO IT TO BEGIN WITH. | |
Re: >if(printf(5+"Good")>0) There's nothing to explain. This program is broken. Change the 5 to a 4 and you won't invoke undefined behavior, but nothing will be printed because you're sending printf an empty string. If you add 1 to "Good", you get "ood". If you add 2 to "Good", you get … | |
Re: >why is it printing oops Probably because you're mixing signed and unsigned types using negative values. That way lies madness. | |
Re: >From where can i find the header file unistd.h... Start [url=http://www.linux.org/]here[/url]. | |
Re: >But I don't think so that the problem is in goto. No, but goto doesn't buy you anything where a loop is better suited. >BUT, when I am writing the string again, it's not writing the first letter of that string into example.txt Add some prompts to your program. Your … | |
Re: That question is very poorly worded. As far as I can tell, it basically means do this: [code] ofstream foutput ( "somefile" ); Worker w; w.printOut ( foutput ); [/code] By the way, if printOut doesn't use any member functions specific to ofstream, you could make it more general by … | |
Re: Put it on ebay and find out what the people who want it think it's worth. | |
Re: >Element* Stack::Element::Prev(void) How about: [code] Stack::Element* Stack::Element::Prev(void) [/code] |
The End.