2,384 Posted Topics
Re: 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 / … | |
Re: [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 */ | |
Re: 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 … | |
Re: I haven't looked at [URL="http://www.daniweb.com/code/snippet150.html"]this[/URL] in ages, but it seems related. | |
Re: [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] | |
Re: [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 … | |
Re: 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 … | |
Re: 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? | |
Re: 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 … | |
Re: When you create the project, create a Console Application, not a GUI Application. | |
Re: 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] | |
Re: 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) ) … | |
Re: [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. | |
Re: Before the call to Join(), is there another function that leaves unread input (such as a trailing newline) in [icode]cin[/icode]? | |
Re: [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.) | |
Re: [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. | |
Re: 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]. | |
Re: [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047589067&id=1043284376]NULL, 0, \0 and nul[/url] | |
Re: 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 … | |
Re: [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]. | |
Re: 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); … | |
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 … | |
Re: [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 … | |
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. :| | |
Re: [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 … | |
Re: [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 … | |
Re: [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. | |
Re: During the time you can edit, delete it. Otherwise PM a mod for the forum. | |
Re: I can't find the most of the forums I'm looking for in the menu. I find my way using other means. | |
[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 … | |
Re: 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: | |
[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] | |
Re: [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" … | |
Re: [URL="http://www.huffingtonpost.com/harold-ambler/mr-gore-apology-accepted_b_154982.html"]Mr. Gore: Apology Accepted[/URL] | |
Re: [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 … | |
Re: [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] | |
Re: I sent Cheney a nasty email with a link to your DW page. Keep an eye out for tax audits! j/k | |
[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 … | |
Re: [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: | |
Re: Considering that there's a link at the bottom of every page, I can't see much hoopla about this. | |
Re: 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. | |
Re: [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] | |
Re: [url]http://www.daniweb.com/search/search.php?q=strcpy+code+snippet[/url] doesn't seem to produce the results I would like. | |
Re: 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. | |
Re: [url]http://www.daniweb.com/forums/showthread.php?p=509920#post509920[/url] | |
Re: 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"); … | |
| |
Re: [url]http://en.wikipedia.org/wiki/Comparison_of_social_networking_software[/url] | |
Re: [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? | |
Re: [url]http://directorblue.blogspot.com/2008/11/crazy-floor-and-ceiling-murals.html[/url] |
The End.