2,384 Posted Topics
Re: [QUOTE=Ravalon;310014]Good examples are hard to come by when the examples are factorials, fibonacci calculations, and the towers of hanoi. :rolleyes: Factorials can be more easily solved with a simple loop, recursive fibonacci algorithms are usually too inefficient to show the beauty of recursion, and the towers of hanoi can be … | |
Re: [INLINECODE]goto[/INLINECODE] is widely criticized from where it was rightfully criticized -- BASIC. C and C++ are not BASIC. The same rules don't really apply. It can be abused in C and C++, but this is not 1979, and the languages are different. So avoiding it for historical reasons in an … | |
Re: Sure. Feel free to post a description of the problem -- as long as you also post your latest attempt at a solution. Start there. Finish with your goal accomplished. | |
Re: [QUOTE=Nsin;309695]in one of the header file I have declared #define GPSINIT "version no"[/QUOTE]That's not a variable. If it was, you could find out where the variable is quite easily. As you have it, there may be more than one of these here and there, so finding where "it" exists is … | |
Re: This topic was discussed not too long back on the mod board, I believe. Y'all might want to look it up before rehashing too much -- that is, if it already hasn't been mentioned or reincarnated there. | |
Re: [url=http://www.daniweb.com/tutorials/tutorial45806.html]User Input: Strings and Numbers [C][/url] | |
Re: Minor nit, ~s.o.s~, the initial examples by the OP were expressions and not declarations. [QUOTE=pointers;308374]I am a basic learner in C language.Could u please provide me a good link or tutorial or explanation regarding "order of precedence". I have the table of "order of precedence"........but needed some examples. I am … | |
Re: [QUOTE=joeprogrammer;308208]As far as I know, there isn't a way of getting the enum's name directly from the number is represents.[/QUOTE]Purely as an aside as such things may be of interest... [url]http://cboard.cprogramming.com/showthread.php?p=186539#post186539[/url] | |
Re: [aside]Ads and such as I've previously mentioned, or my attempts to circumvent them, have apparently gotten me to subconsciously call this site [I]PokyWeb[/I]. The looooong load times for me, compared to other similar sites, and that all-too-annoying "jumpiness" really continue to help me further back-burner DaniWeb while other sites are … | |
Re: [QUOTE=WaltP;307390]Yeah, what [B]Ravalon[/B] said. You can check out [url=http://www.gidnetwork.com/b-59.html]this series[/url] for deeper understanding of why we say "stop using [INLINECODE]sscanf()[/INLINECODE]"[/QUOTE][INLINECODE][COLOR="Blue"]s[/COLOR]scanf[/INLINECODE]? | |
Re: I saw this at the bottom of this page under Similar Threads: [thread=31665]How to make console programs full screen?[/thread] | |
Re: Or possibly calculate it to initialize a const value once using [INLINECODE]atan[/INLINECODE] or somesuch. That way you can be fairly sure that your copy of pi is at the implementation's best ability portably. | |
Re: [QUOTE=JoBe;304191]Hello ladies and gents, Ive got a few more expressions I needed to fully parenthesize: 1) *p++ becomes *(p++) 2) *--p becomes nothing if *--p would have been --*p: --*p OR--(*p) would have the same result. Reason is, both would have the same precedence, so, it goes from left to … | |
Re: [QUOTE=Marks256;304861]Well, there it is! I am pretty proud of it, too! It will calculate fibonacci to n digits... :D Since i am new to c (i am moving from QBASIC to [COLOR="Magenta"]C/C++[/COLOR]), i would like to hear some criticism about it. Productive only, please... :)[/QUOTE]Treat C and C++ as separate … | |
Re: The C standard library offers several conversion functions. [list=1][*][INLINECODE]strtol[/INLINECODE] - best error checking [[URL=http://www.daniweb.com/code/snippet441.html]demo[/URL]] [*][INLINECODE]sscanf[/INLINECODE] - some level of error checking [[URL=http://www.daniweb.com/code/snippet266.html]demo[/URL]] [*][INLINECODE]atoi[/INLINECODE] - poor level of error checking[/list]But for C++, I'd recommend looking into [URL="http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2"]stringstreams[/URL]. | |
Re: [url]http://cboard.cprogramming.com/showthread.php?t=84349[/url] [url]http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf[/url] <- Find Annex J in here. | |
Re: [QUOTE=joeprogrammer;304018]The editor I'm currently using (Xcode) doesn't work quite as nicely; it indents what the previous line was indented, so I have to do a lot of tabbing and deleting sometimes. Sooo... the point I was trying to make was, [COLOR="Blue"]get yourself a good editor[/COLOR][/QUOTE]Although I try not to proselytize … | |
Re: [QUOTE=mehakkapur;302795]If you have to count numbers of 1 in a 32 bit word. Other than checking every other bit or dividing the bits is 4 parts and then using lookup table. What will be some other most efficent way ?[/QUOTE]You're ruling out [URL="http://infolab.stanford.edu/~manku/bitcount/bitcount.html"]these[/URL]? | |
Re: This is a very bad no-no: [code] [COLOR="Magenta"]char* input;[/COLOR] printf("Enter the snack's name: "); [COLOR="Magenta"]scanf("%s", input);[/COLOR][/code]This is C++ or C99: [code]int lookup(char snack[]) { convert_lowercase(snack); [COLOR="Magenta"]const int available_snacks = sizeof lookup_table / sizeof *lookup_table;[/COLOR] for([COLOR="Magenta"]int[/COLOR] i=0; i!= available_snacks; i++) [/code]I'd recommend cleaning these up and making it C90 if it's … | |
Re: [QUOTE=Ancient Dragon;301978]MS-Windows fgets() appends a '\n' at the end of the line, which you must remove. [code] while (fgets( // blabla ) ) { if( line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; } [/code][/QUOTE]I wouldn't say it [I]appends[/I] it, but rather [I]leaves it there[/I] if in fact it is there. And … | |
Re: [QUOTE=joeprogrammer;297947]Narue and her family must have had a [I]very[/I] happy time this Christmas, as her baby was born on Christmas [COLOR="Magenta"]day[/COLOR]. Her daughter is 8 lbs, 8 oz, and is 20.25".[/QUOTE]Nitpicking as always, but I understood it to be the night before. And I'm only going with the boy/girl guess … | |
Re: [QUOTE=Aia;299848]Many times in books and tutorials I'm sent to consult the Standard C Library reference. Sometimes, references are made to some Standard C function.[/QUOTE]Perhaps no better place to look is the standard itself -- or at least a [URL="http://cboard.cprogramming.com/showthread.php?t=84349"]publicly available draft[/URL] thereof. | |
Re: [list][*]I can't type [INLINECODE]break;[/INLINECODE] without the semicolon -- in code or in text (I've got an "automatic" backspace built into my fingers for specifications in which I use "break"). [*]Half of the time [INLINECODE]te[COLOR="Blue"]x[/COLOR]t[/INLINECODE] comes out [INLINECODE]te[COLOR="Magenta"]s[/COLOR]t[/INLINECODE]. [*][INLINECODE]dat[COLOR="Blue"]e[/COLOR][/INLINECODE] all too often comes out [INLINECODE]dat[COLOR="Magenta"]a[/COLOR][/INLINECODE]. [*]I can't do the number row … | |
Re: [QUOTE=jbennet;297963]there good for getting non computer literate folk into the field[/QUOTE]If you're serious enough about something so that your willing to plunk down your own hard-earned cash, why would you choose something that teaches you something half-assed rather than something that does the complete job? | |
Re: [QUOTE=Aia;297469]I have been trying to figure out how to deal with any situation when the result is bigger than what a integer declared can hold.[/QUOTE]I believe your actual question was addressed with GMP. But with the code you posted, a good compiler or linter ought to tell you something like … | |
Re: [url]http://en.wikipedia.org/wiki/Data_structures[/url] [url]http://en.wikipedia.org/wiki/List_of_data_structures[/url] | |
Re: [QUOTE="Global Warming: Myth?"][I]MYTH: Even if the Earth is warming, we can't be sure how much, if any, of the warming is caused by human activities.[/I] [B]FACT: There is international [COLOR="Magenta"]scientific consensus[/COLOR] that most of the warming over the last 50 years is due to human activities, not natural causes.[/B] [COLOR="Magenta"]Over … | |
Re: [QUOTE=Wreef]I was just wondering if people could tell me what they think is the best way to learn C++[/QUOTE]Writing code. A lot of people post questions here. Attempt to answer them. The critiques you get are wonderful for learning. [QUOTE=Wreef]Recomend a book, ect.[/QUOTE][url=http://www.daniweb.com/techtalkforums/thread10232.html]C++ Books[/url] (skickied in this forum) [QUOTE=Wreef]But the … | |
One of my favorites, very frequently brings a smile. [flamesuit=on] Comments? [/flamesuit] | |
Re: [QUOTE=anjutalks;294865]Hello, i really need code for creating a binary search tree from pre-order and post order traversals.......and print its output in post order and level order traversals....pls help...[/QUOTE]Your best bet is to do your own homework, read your own textbook, etc. But if you insist on doubling your effort, start … ![]() | |
![]() | Re: What memory model? BC5 supports the huge model. If you split the variables among several files (as already suggested several times) and use a memory model that supports more than 64K of data, it may work. I was able to do so in BC5. |
Re: [QUOTE=jwenting;291065]smokers however do cause severe problems for non-smokers indirectly even when they don't expose those non-smokers to their smoke. The far higher incidence of serious respiratory problems among smokers is a large drain on healthcare resources which are (in many countries) paid for by taxpayers at least in large part. … | |
Re: Beaten to the punch, but I might have said something like this... [code]#include <stdio.h> #include <time.h> int main (void) { time_t t = time(0); if ( t != (time_t)-1 ) { struct tm* data = gmtime(&t); if ( data ) { data->tm_hour -= 5 + data->tm_isdst; t = mktime(data); if … | |
Re: Instead of reinventing the wheel as an octagon, consider prior art: [url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2[/url] [url]http://www.daniweb.com/code/snippet266.html[/url] ![]() | |
Re: Maybe the C++ version was supposed to use `.find()`? This is enough room for one character plus the terminating null: char letters[2]; | |
Re: The first one allows you to have tighter control of the scope; that is, which functions are able to "see" that prototype. In this case, only main. If you want a function available to more than one function, however, you would need to repeat the prototype in each function that … | |
Re: Isn't this leaking memory (aside from the fact that no attempt is made to delete the lost memory)?[code] struct tm* [COLOR="Magenta"]local_time = new tm( )[/COLOR] ; [COLOR="Magenta"]local_time = localtime( &now )[/COLOR] ;[/code]It is also a good habit to check return values. [url=http://www.daniweb.com/code/snippet264.html]Time - Displaying Current[/url] Change the format fed to … | |
Re: I believe it's already been mentioned or hinted at already, but "Game Programming" is not necessarily about programming games, per se. It is about integrating things like graphics (to a large degree), sound, and other stuff into a program. So such things would not belong in many language proper forums. … | |
Re: I asked pros to do it, but thus far no comment. [url]http://community.slickedit.com/index.php?topic=531.msg2249#msg2249[/url] I think it would be a wonderful combination of advertising a product with making [I]me[/I] see code "How I Like It"(tm). Que sera, sera. Perhaps it needs a demand-side kick. ![]() | |
Re: [QUOTE=Rashakil Fol;280127]No, you can do it without a pointer (or by using a pointer that would be there already, like the stack pointer).[/QUOTE]Do also consider cases in which there is no such thing as a stack or a stack pointer -- the languages evolved from such situations. | |
I fought for and again miss the lack of being able to highlight what I would like to point out using color. Yes there are the [highlight] tags, but I used to use magenta for bad and blue for good -- kinda like the old days when red meant delete, … | |
Re: [URL="http://en.wikipedia.org/wiki/Thanksgiving"]Thanksgiving[/URL] My tradition:[indent]Eat Drink Watch [URL="http://en.wikipedia.org/wiki/American_football"]Football[/URL] Visit with family and friends Relax[/indent](In no particular order.) Sometimes my immediate family goes back to our hometown, in whole or in part. Sometimes -- like this year -- we're all on our own (but phone calls are made to the missing parties). We're … | |
Re: Merged threads: [I]indianscorpion2[/I], please don't start new threads with the same topic in a relatively short period of time (a couple days). If you haven't had any success, how about starting with a failed attempt? | |
Re: A book that might be useful: [url=http://www.amazon.com/exec/obidos/ASIN/1578201039/ref%3Dase%5Fjeanjlabro/002-6221795-9668807]MicroC OS II: The Real Time Kernel[/url]. Jean Labrosse's site is [url]http://www.ucos-ii.com[/url]. | |
Re: char *malloc(); The prototype for malloc is as follows. void *malloc(size_t size); --- A = (int *) malloc( 10 * sizeof(int) ); The sizeof() In C the cast is unnecessary and may potentially mask a failure to #include <stdlib.h>, which can lead to undefined behavior. In C++ you should be … | |
Re: I'm probably getting more peeved than Narue. It is absolutely maddening at times. And it is moreso here than any other forum [edit]that I regularly visit[/edit] -- but DevShed is close. | |
How much extra work is it for ya to make "printer-friendly" versions of blogs and snippets? | |
Re: Are you [INLINECODE]using namespace std[/INLINECODE]? | |
Re: FYI: [url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid Loop Control Using eof()[/url]. |
The End.