6,741 Posted Topics
Re: Are you high? What makes you think anyone but God can help you with a question like that? | |
Re: [B]>And in relation to the code I posted, why couldn't I have the '\n'?[/B] If there's whitespace in the format string, scanf will extract whitespace characters ([i]any[/i] whitespace character, so '\n' is no different from ' ' or '\t' in both the stream and the format string) until the next … | |
Re: [B]>i,ROBOT >Will Smith fights a robot conspiracy to break the >"a robot can't harm a human" union rules.[/B] Read Asimov's short stories under the same name. You'll be even more impressed than some cheesy action knockoff could offer. I, Robot and I am Legend are two good examples of the … | |
Re: Endianness is about byte order, not bit order. So 00000000 00000000 00000000 00000011 in little endian is 00000011 00000000 00000000 00000000 in big endian. Keep that in mind when doing your conversions. | |
Re: The cast to a wide string type should raise red flags. Perhaps you should consider wchar_t and swprintf from the get-go instead of trying to drop narrow characters into wide holes and hoping for magic. | |
Re: [B]>I saw this question in a site and tried to solve this but I have no idea can you help me?[/B] If you tried, then show us your attempt and what you learned from the failure. This is pretty close to the easiest of recursive problems, so I'm inclined to … | |
Re: Sorry, but you're going to have to fix the formatting of your triangles. I added code tags to preserve the spacing, but it looks like you used Daniweb's input box to format everything. The input box doesn't use a fixed width font type, so what looks good when you type … | |
Re: [B]>i would like to know more about the book before i buy it.[/B] FYI, TAOCP consists of several volumes, and it's concentrated awesome. If I could only keep one of my books (I have many), it would be TAOCP (probably volume 3). [B]>Reviews as to how the Math in it … | |
Re: >the solution i need to obtain is >sum[i] = A[i][j] + B[i]; What are the types of A, B, and sum? I really don't see what the problem is unless A[i][j] and B[i] are incompatible for addition, or sum[i] can't hold a value of the result. | |
Re: TCL is a fun language...not as fun as Perl though. ;) Try [url=http://www.tcl.tk/]this site[/url]. | |
Re: You want a very high level programming domain-specific programming language. Treat the problem as such and you'll be less confused as how to proceed. However, creating a language (even a simple one) can be a surprisingly difficult undertaking if you're new to that particular field. I'd suggest making your "algorithm" … | |
Re: [B]>hey can someone explain O(logn) and not O(n)[/B] [URL="http://www.eternallyconfuzzled.com/arts/jsw_art_bigo.aspx"]Clicky.[/URL] | |
Re: I don't have a problem with the link, but please don't cross post it again. | |
Re: >Based on the O notation, approximately how many swaps and >comparisons occur when Selection sort is called on a worst-case array of length 8? That's very poorly worded. Also, there's no such thing as a worst case for selection sort. The best, average, and worst cases are all identical. | |
Re: There's no way to specify the orientation of a file opened by CreateFile, it's always binary. ReadFile and WriteFile work with raw bytes. >What I'm trying to do is to open file in binary mode and then to write >strings so that cannot be opened and examined with Notepad. Printable … | |
![]() | Re: Did you link to wsock32.lib? |
Re: The error will also tell you what assertion failed and where it failed. Basically it means you used a library class or function the wrong way, such as passing a null pointer to strcpy. | |
Re: >Plz answer my these C doubts- "Doubt" is sometimes synonymous with "question", but not in this case. It's very common to ignorantly use doubt in place of question, and it's usually wrong. What you have a C questions, not C doubts. >I dont want to know abt the scope of … | |
Re: calloc is essentially this: [code=c] void *calloc ( size_t n, size_t size ) { void *base = malloc ( n * size ); if ( base != NULL ) memset ( base, 0, n * size ); return base; } [/code] The difference is that the bytes are set to … | |
Re: >im findin it hard to get topics to work on ? We get about ten threads every few days asking for suggestions. Why don't you use one of those? | |
Re: Hmm, none that I know of. You'll probably need to pick a discipline and derive the techniques of algorithm design and analysis from that discipline. May I suggest sorting? Sorting algorithms are full of useful ideas for other algorithm disciplines, they're [B]heavily[/B] researched, and you can find tons of information … | |
Re: [B]>Am I correct?? I only want to verify.. Please answer.[/B] Pretty much, yes. [B]>So in link list, am I supposed to follow the same idea?[/B] The underlying concept doesn't change. However, note that while arrays give you fast random access, linked lists aren't nearly as forgiving. One benefit of merge … | |
Re: >i dont know how to reverse the string in memory How would you reverse "a"? Do nothing, clearly because the reverse of "a" is "a". What about "ab"? Mightn't you just swap the characters like this? [code] char save = str[0]; str[0] = str[1]; str[1] = temp; [/code] Keep adding … | |
Re: [url]http://en.wikipedia.org/wiki/Event-driven_programming[/url] | |
Re: [B]>Is seems C++ does not have a stream class that supports a read/write in the same open mode.[/B] You should do a little more reading on open modes with the fstream class. Read/write mode is both supported and common. The only caveat is the same as with C streams: when … | |
Re: [B]>but why the variable number_value is 0. >I expect the value of 7.[/B] Deep under the hood (for g++), number_value is getting set to 0.0 because the "a" is read as a floating-point value and fails to be converted by strtod, which returns 0 if no conversion can be made. … | |
Re: [B]>which books is most efficient for a totally beginner to programming, C++?[/B] That really depends on you. Everyone learns differently; a great book for one might not be as good for another because of the way concepts are taught. Given a list of recommendations, the ideal is to have a … | |
Re: Define "help", because it looks a lot like you want someone else to solve it for you. | |
Re: Both your min and max variables are uninitialized. Set them both to the first item in the array. As for the average problem, you're printing the average inside the loop rather than after it completes. The loop should only be summing the items: [code=cplusplus] for ( int i = 0; … | |
Re: [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx"]Clicky[/URL]. | |
Re: Yes and no. It depends upon whom you ask, but a common distinction is that the software engineer is more involved in the design aspects than the programmer, who simply churns out code according to an already specified design (ie. a code monkey). | |
Re: >It just outputs a space on the konsole window and then hitting enter makes a new line... That's correct behavior. Input in C++ is line oriented. If you want to just hit a space and have it be recognized immediately, you need to use a non-standard function such as getch … ![]() | |
Re: 7-bit ASCII is a strict subset of UTF-8, no conversion of values is necessary. | |
Re: [B]>It looks that u have not understood the question.[/B] I don't understand either. I'd wager that the problem isn't with us, it's with your ability to ask a coherent question. | |
Re: Just one question, what were you expecting to happen with this? [quote] [code] for(int i=0; i<a.elements; i++) delete[] &a.element[i]; [/code] [/quote] All you need to do is the inverse of what you did to allocate the memory: [code] void deallocate(GrowableArray &a) { delete[] a.element; } [/code] | |
Re: It's pseudocode, there aren't any rules to follow, just make sure your logic is sound. Some people find flowcharts more intuitive, so you could start with that part of the assignment and derive the pseudocode from your result. To be perfectly frank, this smells like a Programming 101 assignment. I … | |
Re: Most likely your strings aren't being terminated with '\0'. What does the file look like? | |
Re: [B]>The C Programming Language...[/B] No, The C Programming Language (also known as K&R) is a fabulous book for learning C90 [i]if[/i] you already know how to program in another language. It's not very friendly to absolute beginners though. [b]C Programming - A Modern Approach[/b] by K. N. King is often … | |
Re: You need to compile GradeBook.cpp as well. Only headers need not be compiled: [code] g++ main.cpp GradeBook.cpp -o main [/code] | |
Re: for(int i=0; i<count; i++) { data.push_back(input); } This is your input loop, but there's no input going on. You need to give the user time to input a value, then add the value to your vector: for (int i = 0; i < count; i++) { if (cin>> input) data.push_back(input); … | |
Re: [B]>Obviously, the raw array is faster than the dynamic array of ublas and multi_array.[/B] Not by much, and the small difference can easily be attributed to the overhead of member function calls vs. direct indexing. So ask yourself one question: Is the difference a deal-breaker for using Boost? You really … | |
Re: [B]>It's standard, if not for beginners.[/B] Which is the single most annoying problem with how C is taught. Pointers are an integral part of the language, and really very simple conceptually. It's my opinion that they should be introduced as early as possible. [B]>Three ampersand (star) programmers are generally mocked … | |
Re: Wow. While I'm sure this isn't a record, one lazy student asking for "help"[1] on an assignment followed immediately by another lazy student hijacking the thread asking for "help" on an unrelated assignment is a wonderful example of the present progression toward the fall of Daniweb. [1] "Help", of course, … | |
Re: You're overwhelming yourself. Start by reading the file and printing out each character, one-by-one. Break the problem down into smaller problems that are easier to tackle individually. Little successes are important, and having something simple that works is much better for keeping your spirits up while working on a problem … | |
Re: [B]>What are the default values of the fundamental types?[/B] That's a fun little can of worms. :) | |
Re: I'll wait to see what the other people reading this thread have to say before giving you a good solution. :) | |
Re: Two things: [list=1] [*]tolower doesn't take a reference parameter, it returns the converted character if such a conversion exists. The immediate problem in your code is that you aren't saving the converted character back into ret[[I]x[/I]]. [*]tolower will accept any value in the range of unsigned char or EOF. If … | |
Re: [B]>BST::~BST();[/B] How is it non-recursive when you try to call the destructor recursively (not a good idea)? Personally, I'm a fan of unraveling the tree into a vine to simplify destruction. Then it just becomes a linked list destruction algorithm: [code] BST::~BST() { BinNodePtr save; for (BinNodePtr it = myRoot; … |
The End.