6,741 Posted Topics
Re: I want a publisher to let me write a book on C. But wanting something doesn't make it happen, especially when it involves other people doing work for you with no benefit to them. | |
Re: [B]>Well, that was a giveaway. I answered 'YES'.[/B] The giveaway was that the statement is so biased as to be immediately false. The king of all languages and the best ever made? You seriously answered yes to that? :D [B]>It's been like 7 years, but C++ still holds its rank … | |
Re: [B]>Hmm... keeping the dictionary in an external file seems like the best approach to me. Correct me if I'm wrong.[/B] How do you suggest looking up a word? Search the file each time? Unless it's a properly designed external database, that's going to be very inefficient. The words will likely … | |
Re: Assuming you need to do it all manually, how about redirecting output to a temporary file? Then you can echo the temporary file to the screen as well as append it to your log file. | |
Re: [B]>First C compiler program compiled on which compiler..???[/B] Unknown, but probably either an assembler or Ken Thompson's B compiler on the PDP-11. | |
Re: I like the explicit nature of the new rules. They should be much easier to enforce as well as making more sense to regular members. | |
Re: Technically it is cleaned up, unless you're on a platform that doesn't reclaim dynamic memory for a process when the process terminates. But if you mean the pointer is never deleted explicitly, that's easy enough. Just print something in the destructor, throw an unhandled exception, and watch the message never … | |
Re: [B]>Is it just me, or do you find your patience stretched rather thin when posting here at Daniweb sometimes?[/B] Sometimes? When the majority of questions are students looking for a handout, a constant state of zero patience is normal. Though I have infinite patience for people who are truly interested … | |
Re: >Because these are the mother languages and if u master these >language it will not take much time to learn other languages. Cool, so if I learn C, C++, or Java then I can pick up Lisp, Forth, or Assembly with no problem? What, pray tell, are these the mother … | |
Re: The two aren't related. Assertions are for catching bugs in the code, exceptions are for managing legitimate errors when the program runs. | |
Re: Adak forgot to allocate memory to molid and molc. For testing purposes, just make those large arrays and see if it works better: [code] struct estr_reg { char molid[BUFSIZ]; char molc[BUFSIZ]; }; [/code] | |
Re: Teachers don't give assignments to do things that haven't been discussed in class. Please don't treat us like idiots. Try asking your question again, this time with enough detail for someone to actually answer it. | |
Re: [B]>the most useful programming languages are ASP.NET,PHP,java[/B] According to TIOBE, Java is the most popular language, and PHP is 4th (with C and C++ in between). But seeing as ASP.NET is a framework rather than a language, your credibility is suspect when it comes to listing the most useful languages … | |
Re: [B]>So kindly hlp me out to decide it...[/B] I fail to see how we can help. We know nothing about your knowledge or about you...except that you're exceedingly uncreative and generally clueless about what you've been studying for the last N years. | |
Re: Once link becomes a null pointer, you've left the realm of the tree. Assigning to link at that point does nothing productive. What you need to do is save a pointer to the last node before link become null, and then assign tmp to either the lc or rc link … | |
Re: [B]>char *timeBegin = (char *)malloc(sizeof(char) * 21);[/B] timeBegin is assigned a pointer to dynamic memory. [B]>timeBegin = time_stamp();[/B] timeBegin is immediately re-assigned to a different pointer, which is not dynamically allocated. The first pointer returned by malloc is [i]lost[/i] forever, thus causing a memory leak. [B]>free(timeBegin);[/B] You're not allowed to … | |
Re: What will you do when stdout is redirected to a file? The file descriptor approach is conventional, and your flag idea seems awkward at best. There will be a lot of special cases with the flag while a file descriptor just works naturally. | |
Re: >But then i have to modify the inner loop to instead of starting >from 1 each time, start from a value that increments the start value. Currently you set numCtrl to 1. What happens when you set it to 1 + linCtrl? :) >Lastly, the spacing.... crap.... Add another loop … | |
Re: >I just want to validate that the entered text in the text box is of correct format(date type). Try to [url=http://msdn2.microsoft.com/en-us/library/system.datetime.tryparse.aspx]parse[/url] it. | |
Re: Read code, write code, read any literature on C you can find. There's no magic bullet, just hard work. | |
Re: This is a trivial homework assignment and we won't help you cheat. Do it yourself. | |
Re: [B]>no it doesnt ..[/B] Did you use it correctly? [code] fprintf(stdout,"hello-out"); fflush(stdout); fprintf(stderr,"hello-err"); [/code] stdout is buffered by default while stderr is not. The three ways to flush a buffered stream are filling it up ("hello-out" is unlikely to do that), printing a newline (which you don't), and calling fflush. | |
Re: [B]>Well, casting is not the same thing as typecasting.[/B] Erm, yes it is. [B]>Typecasting just creates an "alias" (another name), your program >can use, for a certain datatype (typically a struct name).[/B] You're thinking of typedefing. Casting, typecasting, explicit conversion, and type coercion are pretty much the same thing. [B]>A … | |
![]() | Re: Memory errors are funny beasties. One reason they're so hard to debug is the symptoms are often unpredictable. So while I would be thrilled to get a SIGABRT, I wouldn't expect or rely on it. |
Re: [B]>I know that by declaring a variable as 'const', its stored in read only memory[/B] Incorrect. There's no rule that says const qualified objects must be stored in read-only memory. [B]>I found that a const variable's value can be changed using pointers.[/B] Maybe, maybe not. Attempting to modify the value … | |
Re: [B]>If I have to have an abstract base class with all functions from every derived >Node class, why don't I just have one Node class with heaps of functions in?[/B] Indeed. Polymorphism is meant to share a common interface with varying behavior. Your problem is trying to use polymorphism with … | |
Re: [B]>Well, unlike C, C++ provides a concept of headers(not header files)[/B] The concept of headers is identical between C and C++. | |
Re: Why do you want to do that instead of learning a proper graphics library? Not that I don't enjoy a nice ASCII art game every now and again, but console-based graphics are a little retro for serious software. | |
Re: Since you already know the range of the sequence, and it's small, and you want non-repeating values, a random shuffle would be a better option than trying to check whether each new number was already generated or not: [code] #include <stdio.h> #include <stdlib.h> #include <time.h> #define N 157 int main … | |
Re: When you overflow or underflow an unsigned type, wrap-around occurs. Due to unsigned wrap-around, -1 becomes the largest unsigned value for the type. One common trick is taking advantage of that effect for decrementing loops on an unsigned counter without having to know the actual range of the type: [code] … | |
Re: [B]>I have to take a course as a requirement for a new job.[/B] They don't offer suggestions? Or are you trying to meet certification requirements for the job? Sorry, but this all sounds very strange to me. [B]>I know that creating libraries doesn't take this long to learn.[/B] Creating [I]good[/I] … | |
Re: [B]>it writes the content two times into the file.[/B] Close. It writes the content once, but because of a common bug you read it twice. [B]>while(!file.eof())[/B] This is the bug. eof only returns true after you've tried and [i]failed[/i] to read from the file. Using it as a loop condition … | |
Re: [B]>this is for an exam that a need here in my job[/B] Your job? Dare I ask what kind of job gives exams that look a lot like elementary CS homework? You're clearly not a professional developer, judging by your code and complete inability to solve this simple problem. | |
![]() | Re: Well, the error tells you what line the error manifests on, so your first step would be to run your program in a debugger (or use debug printfs if you want to go old school) and verify the state of the variables. Most likely one of your indices is incorrect … ![]() |
Re: [B]>If someone can please give me an example on how this is done so I >can use it to refrence to do thi sproject or show me how to do it.[/B] Reference, my ass. Go do your own homework, slacker. | |
Re: [B]>i have made the prog[/B] Then you shouldn't have any trouble proving it. | |
Re: rand is always seeded to 1 by default. You can change that by calling srand. May I suggest [URL="http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx"]this article[/URL]? | |
Re: Read up on operators and how = is a completely different beast from ==. | |
Re: >cannot convert parameter 1 from 'std::string' to 'System::String ^' You're mixing standard C++ strings with C++/CLI strings. There's a fundamental difference in that C++/CLI strings are Unicode based while std::string is char based. The least frustrating solution would be to pick one and stick with it, but you can also … | |
Re: [B]>How could i know the total elements an array can store???[/B] You're guaranteed at least 65535 / sizeof(T) where T is the type of the array. 65535 is the minimum limit for an object in C. | |
The purple bar at the bottom of the page is not working properly when I browse Daniweb on my iPad (presumably the iPhone has the same problem). Rather than stick to the bottom of the browser window, it locks to the original position and obscures everything at that point (which … | |
Re: mw_get_command is recursive. I don't recommend recursive functions that are linear in nature or potentially infinite. Yours is both. A loop would be just as easy to implement: [code] void mw_get_command(char *cmd) { for (;;) { int ch; printf("Enter a command: "); fflush(stdout); /* Trim leading whitespace */ while ((ch … | |
Re: I'd probably use a database, because tables like this usually end up needing far more robust querying than I'd want to write ad hoc. But I don't see a problem with a vector of objects where each object represents the match up if all you're doing is updating, sorting, and … | |
Re: [B]>After reading about this topic and algorithms from the book by Cormen, I started to implement it.[/B] I've written some articles on the subject with C as the implementation language. You may find them more helpful than your book as the code can be plugged in directly rather than requiring … | |
Re: When you use the <c*> headers as opposed to the <*.h> headers, don't forget that everything is now in the std namespace: [code] int x = 300; char out[4]; std::memcpy(out, &x, sizeof(int)); [/code] And memcpy is declared in <cstring>, not <cstdio>. | |
Re: [B]>char accountNum[6];[/B] If you're using std::map, there's probably no restriction on using std::string as well. I'd highly recommend avoiding C-style strings because they're just too awkward. While C++ isn't known for it's string handling capabilities, std::string is still a vast improvement. [B]>map<char,int , ltstr> report;[/B] Assuming std::string: [ICODE]std::map<std::string, int> report;[/ICODE]. … | |
Re: [B]>I am basically trying to see which is the most efficient way of writing this code.[/B] At this point I'd say that trying to micromanage your memory usage and CPU cycles is unproductive. Both options are extremely likely to be fast enough for your purposes, so it doesn't matter which … | |
Re: I'm not hip on the latest web development stuff, but it sounds like you want a CGI script in C++. That could be a good start for research into a solution. |
The End.