2,384 Posted Topics
Re: Does the variable in your loop condition ever change its value? | |
Re: [QUOTE=Acidburn]but now im wondering if you could display just + or - depending on what is entered.[/QUOTE]If it's less than zero, print [FONT=Courier New]'-'[/FONT]; otherwise, print [FONT=Courier New]'+'[/FONT]. [QUOTE=Acidburn]is it possible to put the float which is entered into an array?[/QUOTE]Of course.[code]#include <iostream> int main() { float value[3]; int i; … | |
Re: [code] assert(0 <= subscript && subscript <= size) [/code]If you're going to use [FONT=Courier New]assert[/FONT], use it correctly.[code] assert(0 <= subscript && subscript [COLOR=Red]<[/COLOR] size)[COLOR=Red];[/COLOR][/code]And you may also want to take a peek at this: [url]http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.8[/url] | |
![]() | Re: [QUOTE=odee]did you include conio.h?[/QUOTE] [QUOTE=Geek-Master]when I use clrscr(); it gives me a linker error that it's undefined. Could this be an issue with my library? I'm using Dev-C++ 4.[/QUOTE] [QUOTE=Geek-Master]Am I supposed to alter the header file, I guess to define it?[/QUOTE] For those that aren't aware, the linker does … |
Re: [QUOTE=the b]I am writing a program using a linked list and I am almost to the point where I can compile and run it but I keep on getting this error message: error C2447: missing function header (old-style formal list?). What does it mean? I looked through the code but … | |
Re: [IMG]http://img64.exs.cx/img64/2314/delete3zj.gif[/IMG] | |
Re: [CODE]int numbers[5]; // array [COLOR=Red]char *str; // input string[/COLOR] for(int i = 0; i < 5; i++) // goes from 0 to 4 (as arrays start at 0) { cout << "Enter number " << i << " for the array"; [COLOR=Red]cin >> str;[/COLOR] data = atoi(str); numbers[i] = data; … | |
Re: [url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]Show your attempt first[/url]. | |
Re: [QUOTE=MasashiMikamida]/*1*/if (amtnam1=[COLOR=Red]'Uuq'[/COLOR]) atom1=Uuq;[/QUOTE]The message is telling you that [FONT=Courier New]'Uuq'[/FONT] is an illegal character constant. It appears to be an attempt to be a string constant ([FONT=Courier New]"Uuq"[/FONT]), but you don't compare C-style strings with [FONT=Courier New]==[/FONT]; instead look into [FONT=Courier New]strcmp()[/FONT]. | |
Re: [QUOTE=lida1984]hi plzzzzz help me!!!!!![/QUOTE] Posting more than 0 lines of code will definitely help. | |
Re: [url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]Show your attempt first[/url]. | |
| |
Re: [QUOTE=blacjuice]I have to get the total votes and percent of each vote for this program.I cant figure it out![/QUOTE]There are a couple of syntax errors.[code]float percent(int totalVotes[8]) { int row=0; int sum=0; [COLOR=Sienna]//{[/COLOR] [COLOR=Red]// unnecessary mismatched {[/COLOR] for (row = 0; row < 8; row++) { sum=sum+totalVotes[row]; } return sum/8.0; … | |
Re: [list=1][*]Open MSVC. [*]File->New...{Projects}Win32 Console Application, enter a name - Ok [*]Select "An empty project." - Finish [*]File->New...{Files}C++ Source File, enter a name - Ok [*]Type code. [*][F5] Go or [Ctrl+F5] Execute[/list] | |
Re: >unexpected end of file while looking for precompiled header directive Turn off precompiled headers if you're not using them. [IMG]http://img33.exs.cx/img33/3041/precompiledheaders0go.jpg[/IMG] But by all means, visit some basic tutorials or back up to the beginning of your book first. | |
Re: This is assignment:[code]i = 1[/code]This is comparison:[code]i == 1[/code][edit]And these are [url=http://www.daniweb.com/techtalkforums/misc.php?do=bbcode#code]code tags[/url]: [co[i][/i]de][/co[i][/i]de] ;) | |
Re: Did you know you have unreachable code? [code] switch ( choice ) { case '1': system("CLS"); cout << "\n\n\n\n"; cout << setw(50) << "Thank you for voting. " << endl; cin.get(); [B]break;[/B] [COLOR=Red]cout << setw(30) <<"Please enter supervisors password to enable next voter:" ; getline(cin, password);[/COLOR] case '2': system("CLS"); cout … | |
Re: Surely your compiler is giving you a message? And [FONT=Courier New]endl[/FONT] is spelled with an [FONT=Courier New]l[/FONT] (ell) at the end, not a [FONT=Courier New]1[/FONT] (one). | |
Re: [code]Add: [B]a [COLOR=Red]+[/COLOR] b[/B] Subtract: [B]a [COLOR=Red]-[/COLOR] b[/B] Multiply: [B]a [COLOR=Red]*[/COLOR] b[/B] Divide: (this gets tricky) [B]if(b) a [COLOR=Red]/[/COLOR] b[/B][/code]What have you been trying? | |
Re: [code]#include <iostream> #include <fstream> #include <string> int main(void) { std::ifstream file(__FILE__); std::string word; while ( file >> word ) { std::cout << word << std::endl; } return 0; }[/code] | |
Re: [url=http://www.google.com/search?q=scheduling+%22SHORTEST+JOB+FIRST%22+%22PRIORITY%22+%22ROUND+ROBIN%22+flowchart]Google your terms[/url] for a start. | |
Re: Some ideas:[code]#include <stdio.h> struct student { int id; char name [ 32 ]; double grade [ 4 ]; }; void show(struct student *student) { static const char letter[] = "FDCBA"; size_t i; double sum = 0; for ( i = 0; i < sizeof student->grade / sizeof *student->grade; ++i ) … | |
Re: Two [FONT=Courier New]FILE[/FONT] streams, [FONT=Courier New]a[/FONT] and [FONT=Courier New]b[/FONT], write the same to both. | |
Re: You forgot to post the most important part -- the actual code. I take it you are not using [FONT=Courier New]"%2d%2d%2d"[/FONT] as a format specifier? | |
Re: In main(), where does shape get its value? In triangleShape() where do A, B, and C get their values -- and which shape do you mean? | |
Re: [QUOTE=dalaharp]is there no procedure wherein you can allocate memory by malloc etc..[/QUOTE]Yes. What have you tried? | |
Re: Consider recursion to "get to the bottom" before starting.[code]#include <stdio.h> void foo(FILE *file) { char line [ 128 ], *ch; if ( fgets(line, sizeof line, file) ) { foo(file); /* * Reached bottom. */ fputs(line, stdout); } }[/code] | |
Re: Let me summarize the http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2 announcement: no code, no help. And please use code tags. | |
Re: [code]#include <iostream> using namespace std; int main() { int num; cout << "Please enter a number: "; cin >> num; while ( num ) { cout << num % 10; num /= 10; } cout << endl; return 0; }[/code] | |
Re: It might be a little easier to look at your code if it were enclosed within code tags. Hmmm. You open a file and never close it, then you open it. | |
Re: [code] return sum/12;[/code]Do you want an integer result? Or a float with the fraction not truncated?[code] return sum/12[COLOR=Blue].0F[/COLOR];[/code](This seems to be a recurring theme lately.) | |
Re: yb1pls: [B][COLOR=Red]Let sleeping threads lie![/COLOR][/B] And please learn to use [url=http://www.daniweb.com/techtalkforums/misc.php?do=bbcode#code][CO[i][/i]DE][/CO[i][/i]DE][/url] tags! And read the [url][COLOR=Magenta]Announcement[/COLOR][/url]. And do some searches to find out why [FONT=Courier New]void main()[/FONT] is wrong. | |
Re: average= (tests[0] + tests[1] + tests[2])/3; // assumed fixes cout<< "The average is" <<average <<endl; Lemme guess -- no decimal places? Dividing integers uses integer division. If you want a floating point value, cause floating point division. average= (tests[0] + tests[1] + tests[2])/3.0; // assumed fixes | |
Re: >i don't know what to do with this, i don't even know how to start off. Try: int main() comes to mind. >this is not homework. You're being employed to write this? Look for another job. | |
Re: [CODE]#include <stdio.h> #include <stdlib.h> #include <time.h> int main ( void ) { static const char value[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int i; srand ( time ( 0 ) ); for ( i = 0; i < 6; ++i ) { putchar ( value [ rand() % ( sizeof value - 1 ) … | |
Re: [quote]x->y is shorthand for x.(*y)[/quote]Perhaps you mean [FONT=Courier New](*x).y[/FONT]? | |
Re: This thing? http://cboard.cprogramming.com/showthread.php?p=322171#post322171 Paying attention to error codes or phrases may give you something to google. Posting your code will also be helpful if you need help debugging it. (And don't forget the code tags!) | |
Re: [QUOTE=serfurj]i'm also a bit confused. for example, all of the following code works just fine: please explain which is best and why.[/QUOTE] In all cases, [FONT=Courier New]main[/FONT] should be declared as returning an [FONT=Courier New]int[/FONT], and an [FONT=Courier New]int[/FONT] value should be returned from it. [CODE]#include <stdio.h> main() { char … | |
Re: [QUOTE=Archer]Is my code correct??? I would like to find the percentage like for example: 30pcs of 60pcs is 50%. But how do I code it??? I mean, how to code to get the PERCENTAGE... Is the formula: (num/total) * 100 ??? Is this correct: [code]for(x=0;x<3;x++) { y=total[x]; p[x]=((float)(y/grand))*100; }[/code] I … | |
Re: Use floating point, otherwise the answer is 1. [indent]1 + 1/2[COLOR=Red].0[/COLOR] + 1/3[COLOR=Red].0[/COLOR] + 1/4[COLOR=Red].0[/COLOR][/indent] | |
Re: [code] dist[vnames.size()]; pred[vnames.size()]; undecided[vnames.size()];[/code]??? | |
Re: My guess is that it has something to do with this confusion:[code] float [COLOR=Blue]inPlanet[/COLOR]; int [COLOR=Red]planet[/COLOR]; cin >> [COLOR=Blue]inPlanet[/COLOR]; switch ([COLOR=Red]planet[/COLOR])[/code] | |
Re: [QUOTE=smartintelleng][B]My question is how do I locate the part of my code that causes these warnings. [/B][quote]Compiling... stat.cpp main.cpp Generating Code... c:\program files\microsoft visual studio .net 2003\vc7\include\xstring(1466) : warning C4701: local variable '_Ptr' may be used without having been initialized c:\program files\microsoft visual studio .net 2003\vc7\include\xstring(1466) : warning C4701: local … | |
Re: [code]#include <stdio.h> int main(void) { double value[] = {123.45678,234.12345,34.34567}; int j; for ( j = 2; j <= 3; ++j ) { size_t i; printf("%d decimal places:\n", j); for ( i = 0; i < sizeof value / sizeof *value; ++i ) { printf("%.[COLOR=Blue]*[/COLOR]f\n", [COLOR=Blue]j[/COLOR], value[i]); } } return 0; … | |
Re: [QUOTE=jasweb2002]I need to set a variable to infinity or the highest possible number for the computer. But I have no idea how to do this. I did this a little while dabbling in assembly but I am unsure how to do this in C++. Thanks.[/QUOTE][url]http://forums.devshed.com/showthread.php?p=891652#post891652[/url] | |
Re: [QUOTE=1o0oBhP]I have done a bit of physics programming and linked lists before. Anyone want me to post a tutorial on it???[/QUOTE]This programmer's [URL=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1096239530&id=1073086407]FAQ[/URL] came to mind. She visits here too if you have specific questions on it. | |
Re: What do you think is the loop condition in the following line?[code]while (ch = Infile.peek() != EOF)[/code][edit]Actually that whole loop is wrong. | |
Re: For pseudocode it looks like you're on the right track. [For actual code, there are a number of syntactical issues.] But what are you doing with ounces? You ask for it, but never use it. Similarly, are you planning to do something with grams? Please learn to use [CODE] tags. |
The End.