2,384 Posted Topics
Re: What compiler/OS? There will probably be documentation provided with your system. There may be something like [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dnsquery.asp]this[/url] for Windows, or [url=http://www.rt.com/man/dig.1.html]this[/url] for Linux. | |
Re: [url=http://en.wikipedia.org/wiki/Flowchart]Flowchart[/url], [url=http://en.wikipedia.org/wiki/Pseudo_code]pseudo code[/url]; more of a paper-and-pencil exercise, but if you can capture an image, [url]http://imageshack.us/[/url] can be useful for posting what you have. | |
Re: [code]char state;[/code]The above is only a single character, not a string. [code]if ( state == "AL" || "Al" || "al")[/code]The above is equivalent to the following, which is not what you want. [code]if ( state == [COLOR=Red]([/COLOR]"AL" || "Al" || "al"[COLOR=Red])[/COLOR])[/code]Besides, to compare C-style strings, you use [FONT=Courier New]strcmp[/FONT]. If … | |
These are my bookmarked links to various forums I regularly visit:[list][*][url]http://cboard.cprogramming.com/forumdisplay.php?s=&forumid=4[/url] [*][url]http://www.daniweb.com/techtalkforums/forumdisplay.php?s=&daysprune=&f=8[/url] [*][url]http://forums.devshed.com/f42/s[/url] [*][url]http://www.gidforums.com/f-28.html[/url] [*][url]http://www.tek-tips.com/threadminder.cfm?pid=205[/url] [*][url]http://www.cppworld.com/[/url][/list]What are yours? | |
Re: It looks like you are trying to make some old Borland code for DOS. Perhaps there are some examples in the Code Snippets. | |
Re: Where there is repetition, try to separate the common code. For example,[code] cout<<"Enter your selection please..."; cin>>c; cout<<"Enter the number of dice to roll..."; cin>>n; cout<<"in groups of how many? "; cin>>g; if ( c == 1 ) { D4(n,4); } else if ( c == 2 ) { D4(n,6); … | |
Re: How about this?[code]while ( cin >> x >> y )[/code]What is an example of your input? | |
Re: [code]#include <iostream> #include <string> using namespace std; int main(void) { string text; do { cout << "prompt: "; getline(cin, text); } while ( text[0] == '\0' ); cout << "text = " << text << endl; return 0; } /* my output prompt: prompt: prompt: prompt: hello world text = … | |
Re: Doesn't a Packaging Wizard come with MSVC7? Or did [url=http://www.jrsoftware.org/isinfo.php]Inno Setup[/url]'s stuff do that kinda thing too? I forget. | |
Re: I believe the [url=http://www.boost.org/libs/regex/doc/index.html]boost regex[/url] is frequently recommended. | |
Re: There is no function because there is no need for one. What you see is how you choose to interpret it. [code]#include <stdio.h> int main(void) { char ch = '*'; printf("ch = '%c'\n", ch); printf("ch = %d\n", ch); return 0; } /* my output ch = '*' ch = 42 … | |
Re: First, why are you using the [FONT=Courier New]#include [COLOR=Red]<[/COLOR]header.h[COLOR=Red]>[/COLOR][/FONT] variation? That is generally used for system headers. User headers are generally [FONT=Courier New]#include [COLOR=Blue]"[/COLOR]header.h[COLOR=Blue]"[/COLOR][/FONT]. It makes a difference in where it looks for the files. Second, are you setting up the project correctly for multiple source files? It ought to … | |
Re: Maybe try searching the [url=http://www.daniweb.com/code/c.html]Code Snippets[/url]. | |
Re: I'm not familiar with the libraries you are working with, but perhaps the "'non native', ie like a 'string', or 'vector'" issue is because they are not POD types? | |
| |
![]() | Re: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url] ![]() |
Re: Why don't you use the parameterized constructor? [code]int main() { int d; int b; cout << "Enter number in decimal and the Base to Convert: "; cin >> d >> b; cout << endl; [COLOR=Blue]baseType myBase(d,b);[/COLOR] myBase.decToBase(d, b); myBase.print(); return 0; }[/code] | |
Re: It's late and I'm tired, so here's a [url=http://www.cppworld.com/forum/index.php?showtopic=474&st=0&#entry3390]gift[/url]. Try working it into something of your own and post any problems you are having. Also, read the [URL=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/URL]. . | |
Re: [url]http://www.thefreecountry.com/programming/resourceeditors.shtml[/url]? | |
Re: >but am getting the wrong output Could you be more precise? [url]http://www.catb.org/~esr/faqs/smart-questions.html#beprecise[/url] What is your input? What is your output that is "wrong"? What are a and b? | |
Re: [code] double a=123.456; char msg1[3]; sprintf(msg1,"%g",a);[/code]The string [FONT=Courier New]msg1[/FONT] only has room for 2 characters and a terminating null. And you're trying to write 7 characters plus the null to it. [code]send(sockfd2,msg1,[COLOR=Red]sizeof[/COLOR](msg1),0);[/code]You might mean [FONT=Courier New]strlen(msg1)[/FONT]. | |
Re: [QUOTE=hazzo]Will not work It comes up with the error message "Line 11 `main' must"[/QUOTE]...have return type [FONT=Courier New]int[/FONT]? [QUOTE=hazzo]How do i fix this[/QUOTE]Uh, give [FONT=Courier New]main[/FONT] a return type of [FONT=Courier New]int[/FONT]. [code]int main() { // ... return 0; }[/code] | |
Re: C is commonly used for [url=http://en.wikipedia.org/wiki/Embedded_system]embedded systems[/url]. | |
Re: [quote=amsnme]hi....can anyone pliz tell me how to go about converting numbers to letters on a telephone keypad...... eg when we txt..and suppose we type in 4663,we can get hood,home,good,gone....etc...[/quote]The code you posted seems to be going the other way -- from "home" to 4663. | |
Re: Since you read the [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/url], what code are you having trouble with? | |
Re: Let sleeping threads lie. Instead, refer to them in a new thread. Split thread: refer to this previous thread: [thread]12479[/thread] | |
Re: Something like this? [code]#include <iostream> #include <cstdlib> #include <ctime> [COLOR=Blue]int foo(double percent) { double number = std::rand() / (double)RAND_MAX; /* value from [0,1] */ return number < percent; }[/COLOR] int main() { std::srand(std::time(0)); double pct = 0.1; for ( int i = 0; i < 10; ++i ) { std::cout … | |
Re: >my question is how do you store a fraction such as 2/3 into cin>> ? This is one way. [code]#include <iostream> int main() { char slash; int x, y; std::cout << "fraction? "; if ( std::cin >> x && std::cin >> slash && std::cin >> y ) { std::cout << … | |
Re: [QUOTE=winbatch]And the wonderfully succint error:[/QUOTE][url]http://www.bdsoft.com/tools/stlfilt.html[/url] | |
Re: Why not a [FONT=Courier New]vector[/FONT] of [FONT=Courier New]string[/FONT]s? | |
Re: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608[/url] | |
Re: Is DOS your OS? If not, you may want to learn a graphics API for your platform. | |
Re: In another forum I posted a link to an FAQ: "Accessing a directory and all the files within it". Did you follow the link? | |
Re: [QUOTE=Prahaai]i cant really understand how i use it... i am quite confused, sorry, i am not that good to understand where exactly i put the name of the file i have to read? And i dont understand why you put that (argc == 2)... :cry: [/QUOTE]From the command line.[code]#include <iostream> … | |
Re: I'd imagine something like... [code]double prof[COLOR=Blue] = 0[/COLOR]; // ... while(/*...*/) { [COLOR=Blue]double p = profits(ssg.prodprice, ssg.prodcost, ssg.prodquan);[/COLOR] // ... [COLOR=Blue]prof += p;[/COLOR] }[/code] | |
Re: [code]000013 Farsio Kottab E [COLOR=Red]90013[/COLOR] CA 90755 40 20.00[/code]This gets you into a fail state. | |
Re: Please read the [URL=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/URL]. | |
Re: [QUOTE=t3bruce][code]using dice std; # include <cstdlib> int dice( ) { int. random_ interger = rand ( ) cout << random_ interger << end 1 }[/code]<< moderator edit: added [url=http://www.daniweb.com/techtalkforums/misc.php?do=bbcode#code][co[u][/u]de][/co[u][/u]de][/url] tags >> . Write the member function definitions for each function listed: 1. Object Type: a pair of dice Knows: The … | |
Re: With [FONT=Fixedsys]strcmp[/FONT]. The result would be less or greater than zero.[code]#include <stdio.h> #include <string.h> int main(void) { static const char a[] = "12345620", b[] = "123456708"; int result = strcmp(a, b); printf("%s %s %s\n", a, result < 0 ? "<" : result > 0 ? ">" : "=", b); return … | |
Re: You can't use [FONT=Courier New]float[/FONT]s for array subscripts. | |
Re: Please post code within code tags. Might [this](url=http://www.daniweb.com/code/snippet258.html) help? | |
Re: [code]#include <[COLOR=Red]c[/COLOR]string>[/code]I think you meant this one.[code]#include <string>[/code] | |
Re: This important part looks like it got lost. [code] while ( game1.getlives() != 0 [COLOR=Blue]&& game1.checkstatus()[/COLOR] )[/code] This is how I might write [FONT=Courier New]checkstatus[/FONT]. [code]int hangman::checkstatus() { int i; for ( i = 0; encryption[i] != '\0'; ++i ) { if ( encryption[i] == '*' ) { return 1; … | |
Re: [QUOTE=nizar4445]i know i have to use feof with a while loop[/QUOTE]Uh-oh. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351[/url] | |
Re: Arrays are indexed [FONT=Courier New]a[COLOR=Blue][[/COLOR]i[COLOR=Blue]][/COLOR][/FONT], not [FONT=Courier New]a[COLOR=Red]([/COLOR]i[COLOR=Red])[/COLOR][/FONT].[code]a [COLOR=Red]*[/COLOR] new int[num_cells];[/code]Typo?[code]a [COLOR=Blue]=[/COLOR] new int[num_cells];[/code][code]int=b;[/code]Did you mean [FONT=Courier New]i[/FONT] instead of [FONT=Courier New]int[/FONT]?[code]b=nul;[/code][FONT=Courier New]b[/FONT]? [FONT=Courier New]nul[/FONT]? Learn to use whitespace to make your code easier to read. | |
Re: I am not familiar with [FONT=Courier New]AnsiString[/FONT], so I'd recommend reading the documentation your implementation provides. Some Googling suggests that there are methods [FONT=Courier New]c_str()[/FONT] and [FONT=Courier New]Length()[/FONT] that may be of use. [url]http://www.functionx.com/bcb/topics/strings.htm[/url] | |
Re: You may want to check the man pages for make, or google a tutorial. | |
Re: >what is the header to time code isnt it; I cannot quite parse what you are saying. >#include "pctimer.h" >i keep gettin an error saying no such thing Unless you've created it, this is true. Are you looking for [FONT=Fixedsys]time.h[/FONT]/[FONT=Fixedsys]ctime[/FONT]? |
The End.