2,384 Posted Topics

Member Avatar for phoenix911

At some point, you need to check to see if the sequence adds up to the value in question. Consider something like this as a starting point. [code]void foo(int value, int start) { int i, sum = 0, match = 0; for ( i = start; i <= value / …

Member Avatar for siddhant3s
1
202
Member Avatar for sanushks

[sscanf](http://www.daniweb.com/code/snippet353.html) or http://www.daniweb.com/code/snippet441.html [strtoul](http://www.daniweb.com/code/snippet353.html)? #include <stdio.h> int main() { const char representation[] = "1234"; int value; if ( sscanf(representation, "%d", &value) == 1 ) { printf("value = %d\n", value); } return 0; } /* my output value = 1234 */

Member Avatar for sanushks
0
160
Member Avatar for szcfama

My compiler's code critique: [quote]main.cpp: In function `void addStudent(student*)': main.cpp:89: warning: too many arguments for format main.cpp:83: warning: unused variable 'i' main.cpp: In function `void findStudent(student*)': main.cpp:229: warning: format argument is not a pointer (arg 2) main.cpp: In function `void displayAll(student*)': main.cpp:255: warning: format argument is not a pointer (arg …

Member Avatar for Daiva
0
173
Member Avatar for lagirabo

I haven't looked at [URL="http://www.daniweb.com/code/snippet150.html"]this[/URL] in ages, but it seems related.

Member Avatar for lagirabo
0
101
Member Avatar for kailisr

[code]6.8.5 Iteration statements Syntax iteration-statement: while ( expression ) statement [COLOR="Red"]do statement while ( expression ) ;[/COLOR] for ( expressionopt ; expressionopt ; expressionopt ) statement for ( declaration expressionopt ; expressionopt ) statement[/code]

Member Avatar for tux4life
0
128
Member Avatar for Duki

[QUOTE=Duki;872239]I am trying to convert an array of longs to an array of chars. There are 1081 elements in the long array. Each element is 4 digits long. Is there a function in C++ that will convert a long something I can store in the array or could someone point …

Member Avatar for tux4life
0
250
Member Avatar for sanushks

Consider also [icode]sscanf[/icode]. [code=c]#include <stdio.h> int main(void) { const char line[] = "123#!45!2#!678#!666#!45!6#!"; char text[10]; int n; const char *ptr = line; while ( sscanf(ptr, "%9[^#]#!%n", text, &n) == 1 ) { printf("%s~", text); ptr += n; } putchar('\n'); return 0; } /* my output 123~45!2~678~666~45!6~ */[/code]Although as posted this …

Member Avatar for cool_zephyr
0
212
Member Avatar for jephthah

Something like this, maybe? [code]#define LED_2 PANELRAC_LED_141 #define LED_3 PANELRAC_LED_142 #define LED_4 PANELRAC_LED_143 #define LED_5 PANELRAC_LED_144 #define LED_6 PANELRAC_LED_137 #define LED_7 PANELRAC_LED_138 #define LED_8 PANELRAC_LED_139 #define LED_9 PANELRAC_LED_140 [/code] [edit]No, I guess not. But can you just ignore their version and create your own header?

Member Avatar for jephthah
0
98
Member Avatar for dev565

Try messing about with a skeleton like this: [code]#include <stdio.h> [COLOR="Red"]void foo(FILE *in, FILE *out) { char line[12]; /* pick a size, any size (greater than 1), but do pick a size */ while ( fgets(line, sizeof line, [B]in[/B]) ) { fputs(line, [B]out[/B]); } }[/COLOR] int main() { static const …

Member Avatar for Ancient Dragon
0
942
Member Avatar for Ace01000

When you create the project, create a Console Application, not a GUI Application.

Member Avatar for ArkM
0
179
Member Avatar for rizillion

This[code]cout<<str2+''+str3+''+str1<<endl;[/code] should be this[code]cout<<str2+[COLOR="Red"]' '[/COLOR]+str3+[COLOR="Red"]' '[/COLOR]+str1<<endl;[/code] And this[code]cout<<str1.subtr(1,5)<<endl;[/code] Should be this[code]cout<<str1.sub[COLOR="Red"]s[/COLOR]tr(1,5)<<endl;[/code]

Member Avatar for neigyl_noval
0
98
Member Avatar for kvprajapati

It is often prudent to test around the edges. [code=c]#include <stdio.h> #include <stdlib.h> #include <limits.h> int cmp1(int a, int b) { return a == b ? 0 : a < b ? -1 : 1; } int cmp2(int x, int y) { if ( x - y + abs(x-y) ) …

Member Avatar for Dave Sinkula
0
181
Member Avatar for Sky Diploma

[QUOTE=Sky Diploma;868636]I am unable to understand How and where will such a pointer be useful?[/QUOTE] Consider the [URL="http://www.manpagez.com/man/3/Signal/"]signal[/URL] function as an example.

Member Avatar for Dave Sinkula
0
144
Member Avatar for Deme

Before the call to Join(), is there another function that leaves unread input (such as a trailing newline) in [icode]cin[/icode]?

Member Avatar for Deme
0
212
Member Avatar for ganmo

[url=http://www.daniweb.com/code/snippet488.html]Hex Dump[/url]? (That snippet wasn't always so badly mangled, it once was rather pretty -- skip to line 211.)

Member Avatar for ganmo
0
127
Member Avatar for Talguy

[QUOTE=Talguy;867042]I am passing a dynamically sized 2D array into a function. How would I be able to tell the row size and column size the array.[/QUOTE]When you make the request for dynamic allocation, you know the size. Pass that to the function. The information is not present in the pointer.

Member Avatar for Narue
0
3K
Member Avatar for CoolAtt

This thread reminded me of an old kinda-related one [URL="http://cboard.cprogramming.com/c-programming/54531-using-fgets-removing-last-character.html"]elseweb[/URL].

Member Avatar for Aia
0
5K
Member Avatar for kaku_lala

[url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047589067&id=1043284376]NULL, 0, \0 and nul[/url]

Member Avatar for ArkM
0
133
Member Avatar for kaku_lala

Bear in mind some implementations describe themselves rather than the standard. [quote=n1124]The memcmp function returns an integer greater than, equal to, or less than zero, accordingly as the object pointed to by s1 is greater than, equal to, or less than the object pointed to by s2.[/quote] [quote=n1124]The strcmp function …

Member Avatar for ArkM
0
351
Member Avatar for jaeSun

[code]#include <iostream> #include <climits> int main() { std::cout << std::numeric_limits<double>::max_exponent10 << std::endl; return 0; } /* my output 308 */[/code]With floating point, accuracy and precision have a tradeoff. For floating point modulus, there is [url=http://www.rt.com/man/fmod.3.html][FONT=Courier New]fmod[/FONT][/url].

Member Avatar for tux4life
0
2K
Member Avatar for Philmagrill

Sometimes I choose [icode]sscanf[/icode]. Ballpark? [code=c]#include <stdio.h> #include <ctype.h> void parse_title(const char *text) { char word[128]; /* skip leading whitespace, if any */ while ( isspace(*text) ) { ++text; } /* look for formatted input */ if ( sscanf(text, "<title>%*[^:]: %127[^,]", word) == 1 ) { printf("word = \"%s\"\n", word); …

Member Avatar for jephthah
0
109
Member Avatar for Dave Sinkula

I don't know where to start, so I'll start [URL="http://www.bookwormroom.com/2008/10/04/conservatives-think-liberals-are-misguided-liberals-think-conservatives-are-evil/"]here[/URL]. Let's let liberals/progressives define themselves, and conservatives likewise. But seriously, this reeks of such intolerance, I cannot fathom anyone labeling this "progressive" or "liberal". [quote] Sorry Sashi but the very fact that you are running as a republican disqualifies you …

Member Avatar for jephthah
0
666
Member Avatar for curly3top

[U]dont know where to even begin![/U] Well, then you'll have to help us out there too. >Write a program that reads in an array of type int. Do you know what an array is? Do you know how to create an array of int? >Provide facility to either read this …

Member Avatar for smeezekitty
0
154
Member Avatar for Dave Sinkula

My wireless connection crapped out as I was reading the backlog while I was out. If anyone familiar has I log, I'd appreciate seeing it. Regardless. Let's talk about smokers and smoking. :|

Member Avatar for jbennet
0
4K
Member Avatar for jamboadams

[QUOTE=jamboadams]hey anyone know what the largest value that can be stored in an integer variable is? likewise is there a double / long type of deal that isnt of float type? thanks[/QUOTE][code]#include <iostream> #include <limits> int main(void) { std::cout << std::numeric_limits<int>::max() << std::endl; std::cout << std::numeric_limits<double>::max() << std::endl; return 0 …

Member Avatar for vmanes
0
1K
Member Avatar for krnekhelesh

[QUOTE=krnekhelesh;454920]I want it to be a DOS based program. I have borland C++ the windows based.[/QUOTE]The question is whether or not DOS is your operating system. Don't confuse a console application in Windows with being "DOS". Which, given your reply, is a likely assumption. On what OS do you intend …

Member Avatar for EZO
0
1K
Member Avatar for meabed

[QUOTE=bitforce]An easy way to swap 2 variables without using another variable: [CODE]a=a+b; b=a-b; a=a-b;[/CODE][/QUOTE]Not this again. This is not 1970! Don't do this today or in the future. Use a temp variable.

Member Avatar for Lisa1110
3
1K
Member Avatar for wyerleader
Member Avatar for KeithBolt
0
121
Member Avatar for Dani

I can't find the most of the forums I'm looking for in the menu. I find my way using other means.

Member Avatar for William Hemsworth
0
866
Member Avatar for Dave Sinkula

[QUOTE][URL="http://www.catb.org/~esr/writings/unix-koans/script-kiddie.html"][B]Master Foo and the Script Kiddie[/B][/URL] A stranger from the land of Woot came to Master Foo as he was eating the morning meal with his students. “I hear y00 are very l33t,” he said. “Pl33z teach m3 all y00 know.” Master Foo's students looked at each other, confused by …

Member Avatar for vmanes
1
156
Member Avatar for Aia

There's no change coming -- [URL="http://www.floppingaces.net/2009/01/08/democrats-will-own-this-economy-mess/"]it'll still be Bush's fault[/URL]. :icon_razz:

Member Avatar for GrimJack
0
182
Member Avatar for Dave Sinkula

[URL="http://www.daniweb.com/chat/"]IRC Chat Network[/URL] - the web-based client link brings up the DaniWeb IRC Client, but it doesn't connect. [quote]Trying to Connect - [url]www.daniweb.com[/url] Not Connected. Trying to reconnect in a few seconds... Trying to Connect - [url]www.daniweb.com[/url] Not Connected. Trying to reconnect in a few seconds...[/quote]

Member Avatar for jbennet
0
263
Member Avatar for Salem

[QUOTE=Salem;775761]So, take your idle chat about "restaurants" (link:obesity)[/QUOTE][URL="http://www.csmonitor.com/2009/0107/p09s01-coop.html"]Universal healthcare and the waistline police[/URL] [QUOTE]Imagine a country where the government regularly checks the waistlines of citizens over age 40. Anyone deemed too fat would be required to undergo diet counseling. Those who fail to lose sufficient weight could face further "reeducation" …

Member Avatar for Dave Sinkula
1
162
Member Avatar for kimax

[URL="http://www.huffingtonpost.com/harold-ambler/mr-gore-apology-accepted_b_154982.html"]Mr. Gore: Apology Accepted[/URL]

Member Avatar for sneekula
0
179
Member Avatar for Ancient Dragon

[URL="http://directorblue.blogspot.com/2008/11/bailing-out-uaw-for-bargain-price-of.html"]Bail out the UAW for the bargain price of only $500 billion![/URL][QUOTE] The average American worker makes $25 an hour in wages and benefits or roughly $45K per year. The average American worker employed by Honda, Nissan and Toyota makes $45 an hour in wages and benefits, which translates to …

Member Avatar for GrimJack
0
206
Member Avatar for Salem

[URL="http://directorblue.blogspot.com/2008/12/how-did-dozen-billionaires-get-ripped.html"]How did a dozen billionaires get ripped off in the biggest heist ever? They thought they were cheating average investors[/URL]

Member Avatar for GrimJack
0
318
Member Avatar for vmanes

I sent Cheney a nasty email with a link to your DW page. Keep an eye out for tax audits! j/k

Member Avatar for Dave Sinkula
0
248
Member Avatar for Dave Sinkula

[url]http://mises.org/quiz.aspx[/url] [QUOTE]Your score is: 74/100 [LIST=1][*]What is the correct economic status of private property? [COLOR="Red"]Your answer: The Austrian answer.[/COLOR] [*]What is the proper method to conduct research in economic science? [COLOR="Red"]Your answer: The Chicago answer[/COLOR] [*]What is the reason for the interest rate, and should the rate be regulated? [COLOR="Red"]Your …

Member Avatar for Ene Uran
0
139
Member Avatar for Ancient Dragon

[QUOTE=Ancient Dragon;754017]I'm supprised he didn't try to sell it on eBay.[/QUOTE] [url=http://iowahawk.typepad.com/iowahawk/2008/12/breaking-feds-seize-blagojevich-ebay-account.html]BREAKING: Feds Seize Blagojevich eBay Account[/url] :icon_razz:

Member Avatar for GrimJack
0
156
Member Avatar for mechbas

Considering that there's a link at the bottom of every page, I can't see much hoopla about this.

Member Avatar for Dave Sinkula
-1
237
Member Avatar for mayo_tech11

My advice: history books. Go to an actual library and find books that are a little older and pick your favorite topic. Read them now, because in 20 years the history you read is likely not to be the same.

Member Avatar for techbound
0
2K
Member Avatar for lara_

[list=1] [*][url="http://www.eskimo.com/%7Escs/C-faq/q12.23.html"]Don't use gets[/url]. [*][url="http://www.eskimo.com/%7Escs/C-faq/q12.26.html"]Don't use fflush(stdin)[/url]. [/list]

Member Avatar for Narue
0
2K
Member Avatar for Ancient Dragon

[url]http://www.daniweb.com/search/search.php?q=strcpy+code+snippet[/url] doesn't seem to produce the results I would like.

Member Avatar for Dave Sinkula
1
300
Member Avatar for Ezzaral

For those who have been assimilated by Google, there has been the [URL="http://www.google.com/notebook/"]Notebook[/URL] for some time. It can be nicer in that your notes are there between machines and browsers as well.

Member Avatar for Dave Sinkula
0
141
Member Avatar for Ancient Dragon

[url]http://www.daniweb.com/forums/showthread.php?p=509920#post509920[/url]

Member Avatar for Jen0608
3
400
Member Avatar for rborob

First, I have grown to hate the "while not at end of file" stuff; I now prefer "while successfully obtaining the data I request from the file" approach. Anyways, here is a possible starting point.[code]/* file.txt 003124 */ #include <iostream> #include <fstream> #include <string> int main () { std::ifstream file("file.txt"); …

Member Avatar for namehere05
0
230
Member Avatar for pizzafiend
Member Avatar for samegirl

[url]http://en.wikipedia.org/wiki/Comparison_of_social_networking_software[/url]

Member Avatar for peter_budo
-1
113
Member Avatar for Dani

[QUOTE=happygeek;737772]There is the ability to submit and share blog posts to sites such as Digg and Slashdot at the bottom of each posting. Just hover over the 'Share' button.[/QUOTE] Do the writers ever do that themselves? Sharing to the vast number of services? Even just a quick Tweet?

Member Avatar for Dave Sinkula
0
140
Member Avatar for marketingworld

[url]http://directorblue.blogspot.com/2008/11/crazy-floor-and-ceiling-murals.html[/url]

Member Avatar for mrboolf
1
178

The End.