2,384 Posted Topics

Member Avatar for mattyd

[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 …

Member Avatar for Infarction
0
186
Member Avatar for cusado

[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 …

Member Avatar for WaltP
0
141
Member Avatar for charmee

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.

Member Avatar for WaltP
0
75
Member Avatar for Nsin

[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 …

Member Avatar for Salem
0
119
Member Avatar for tech291083

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.

Member Avatar for tech291083
0
132
Member Avatar for hariza

[url=http://www.daniweb.com/tutorials/tutorial45806.html]User Input: Strings and Numbers [C][/url]

Member Avatar for John A
0
143
Member Avatar for Extremist
Member Avatar for pointers

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 …

Member Avatar for WaltP
0
200
Member Avatar for sbenware

[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]

Member Avatar for Dave Sinkula
0
940
Member Avatar for KevinADC

[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 …

Member Avatar for Dani
0
582
Member Avatar for flageolet

[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]?

Member Avatar for flageolet
0
219
Member Avatar for !=logical not

I saw this at the bottom of this page under Similar Threads: [thread=31665]How to make console programs full screen?[/thread]

Member Avatar for bops
0
2K
Member Avatar for Boldgamer

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.

Member Avatar for Dave Sinkula
0
123
Member Avatar for JoBe

[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 …

Member Avatar for ~s.o.s~
0
191
Member Avatar for Marks256

[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 …

Member Avatar for Nick Evan
0
157
Member Avatar for flageolet

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].

Member Avatar for Dave Sinkula
0
141
Member Avatar for JoBe

[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.

Member Avatar for Ravalon
0
193
Member Avatar for Boldgamer

[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 …

Member Avatar for John A
0
253
Member Avatar for mehakkapur

[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]?

Member Avatar for Ravalon
0
96
Member Avatar for Bench

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 …

Member Avatar for Dave Sinkula
0
3K
Member Avatar for hariza

[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 …

Member Avatar for Dave Sinkula
0
152
Member Avatar for John A

[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 …

Member Avatar for Narue
0
136
Member Avatar for Aia

[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.

Member Avatar for Dave Sinkula
0
256
Member Avatar for roryt

[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 …

Member Avatar for happygeek
0
241
Member Avatar for Elfshadow

[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?

Member Avatar for Colin Mac
0
154
Member Avatar for Aia

[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 …

Member Avatar for Aia
0
190
Member Avatar for bala24

[url]http://en.wikipedia.org/wiki/Data_structures[/url] [url]http://en.wikipedia.org/wiki/List_of_data_structures[/url]

Member Avatar for Dave Sinkula
0
85
Member Avatar for Stuki

[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 …

Member Avatar for Dani
0
283
Member Avatar for Wreef

[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 …

Member Avatar for WoBinator
0
646
Member Avatar for Dave Sinkula

One of my favorites, very frequently brings a smile. [flamesuit=on] Comments? [/flamesuit]

Member Avatar for jwenting
0
79
Member Avatar for anjutalks

[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 …

Member Avatar for iamthwee
0
62
Member Avatar for GreenDay2001

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.

Member Avatar for Dave Sinkula
0
178
Member Avatar for mattyd

[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. …

Member Avatar for Dave Sinkula
0
247
Member Avatar for jobra

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 …

Member Avatar for John A
0
233
Member Avatar for Walkers

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]

Member Avatar for iamthwee
0
151
Member Avatar for JoBe

Maybe the C++ version was supposed to use `.find()`? This is enough room for one character plus the terminating null: char letters[2];

Member Avatar for Dave Sinkula
0
373
Member Avatar for Colin Mac

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 …

Member Avatar for Colin Mac
0
101
Member Avatar for jobra

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 …

Member Avatar for jobra
0
188
Member Avatar for John A

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. …

Member Avatar for Janiceps
0
497
Member Avatar for Dani

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.

Member Avatar for iamthwee
0
547
Member Avatar for TylerSBreton

[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.

Member Avatar for mathematician
0
185
Member Avatar for Dave Sinkula

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, …

Member Avatar for stymiee
0
1K
Member Avatar for Ancient Dragon

[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 …

Member Avatar for Ancient Dragon
0
250
Member Avatar for indianscorpion2

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?

Member Avatar for Nick Evan
0
563
Member Avatar for Ghost

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].

Member Avatar for Ancient Dragon
0
363
Member Avatar for TJW

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 …

Member Avatar for ~s.o.s~
1
410
Member Avatar for Narue

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.

Member Avatar for jbennet
0
597
Member Avatar for Dave Sinkula

How much extra work is it for ya to make "printer-friendly" versions of blogs and snippets?

Member Avatar for yogi_bear_2k2
0
267
Member Avatar for sadsack
Member Avatar for herge
1
109
Member Avatar for waldis

FYI: [url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid Loop Control Using eof()[/url].

Member Avatar for waldis
1
127

The End.