2,384 Posted Topics

Member Avatar for xfruan

The error is correct -- you can't do that in todays C++. Have you been introduced to [FONT=Courier New]new[/FONT]/[FONT=Courier New]delete[/FONT]?

Member Avatar for Narue
0
109
Member Avatar for trevs234

[QUOTE=trevs234]in a book there is a code that i am trying out and my compiler keeps giving me diferent errors (compiler is Borland C++) and i dont know how to fix them.[/QUOTE]You may also want to post the errors.

Member Avatar for vegaseat
0
161
Member Avatar for Maple_Tiger

[Code]int Add (int [COLOR=Blue]x[/COLOR], int [COLOR=Blue]y[/COLOR]) { using std::cout; //Parameters x and y? cout << "In Add(), received " << x << " and " << y << " \n"; return (x+y) }[/Code]The function [FONT=Courier New]Add[/FONT] takes two parameters, [FONT=Courier New]x[/FONT] and [FONT=Courier New]y[/FONT].

Member Avatar for Dave Sinkula
0
76
Member Avatar for lappy512

>im using GCC under linux. Not my area, but I believe [FONT=Courier New][COLOR=Blue]ncurses[/COLOR][/FONT] is a good term to feed Google.

Member Avatar for Tight_Coder_Ex
0
124
Member Avatar for arikeri

You may want to make your tables -- and [I]dummy[/I] input --have [FONT=Courier New]int[/FONT] type. A character [FONT=Courier New]0[/FONT] ([FONT=Courier New]'\0'[/FONT]) is not the same as [FONT=Courier New]'0'[/FONT]. Either that, or use [FONT=Courier New]'0'[/FONT] and [FONT=Courier New]'1'[/FONT] in the [FONT=Courier New]char[/FONT] table.

Member Avatar for Dave Sinkula
0
202
Member Avatar for tyczj

You're actually entering the [FONT=Courier New]%[/FONT] character, aren't you? If so, you'll need to use more complicated input handling, because the [FONT=Courier New]%[/FONT] character is not a valid character in a floating point representation; or else consider entering a fraction such as [FONT=Courier New]0.1[/FONT].

Member Avatar for OurNation
0
155
Member Avatar for shonenhype

[QUOTE=shonenhype]I need to write a program that displays all perfect integers up to 100. I am required to write a boolean function, IsPerfect(), to use in the program.[/QUOTE]A definition of perfect numbers: a number whose value is the sum of its divisors. [QUOTE=shonenhype]Its not that Im asking for the code …

Member Avatar for Dave Sinkula
0
179
Member Avatar for kloony

[QUOTE=kloony]I did try the free(q), but was surprised when the following thing happened: when there were still items on my queue, i did a free(q) and then tried to access items on my queue, it turns out that the first remaining item was not accessible but the 2nd, 3rd item …

Member Avatar for kloony
0
481
Member Avatar for cghv

One thing I see right away:[code] fscanf(cities, "%s \t %s \t %d\n", new_node->city1, new_node->city2, [COLOR=Blue][B]&[/B][/COLOR]new_node->distance);[/code]

Member Avatar for Dave Sinkula
0
174
Member Avatar for arikeri

[QUOTE=arikeri]I not able to decide how to read in a data of the following table[/QUOTE]Are you saying that the following is in a text file? [code]A B(initial values) | x = 0 | x = 1 ------+--------+-------- 0 0 | q=0, y=0 | q=3, y=1 note: q=0 means A and …

Member Avatar for Dave Sinkula
0
110
Member Avatar for arikeri

[QUOTE=arikeri]what is an arrray of fuction pointers?? Plz explain.[/QUOTE]Not the easiest thing to explain, sometimes.[code]#include <stdio.h> int foo(void) { return 1; } int bar(void) { return 2; } int baz(void) { return 3; } int main() { int (*[COLOR=Blue]afp[/COLOR][])(void) = { foo, bar, baz }; int i; for (i = …

Member Avatar for Dave Sinkula
0
134
Member Avatar for tchampion22

[code]#include <iostream> using namespace std; int main() { // your code here return 0; }[/code]And read the [url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]Announcement[/url].

Member Avatar for maj0nes
0
664
Member Avatar for billy-student

[code]int a, b, c, area, tri_area; [COLOR=Red]// computer reads your mind to find out what values a, b, and c should have[/COLOR] area = tri_area(a, b, c);[/code]Plus much, much more. Do you have a specific question?

Member Avatar for Fasola
0
188
Member Avatar for JoBe

Each nibble takes up 4 bits. So shifting by 4 times the desired position would get you to the desired spot.[code]#include <stdio.h> unsigned int set(unsigned char nibble, int pos) { return nibble << ( pos * 4 ); } unsigned char get(unsigned int value, int pos) { return ( value …

Member Avatar for Fasola
0
443
Member Avatar for Foxtildawn

[quote]any help in understanding this would be a great help[/quote]It means you are telling the compiler, "these functions will be available" -- to keep her quiet for compiling -- and then not telling the linker where to find them (or simply withholding them from her). You are teasing the baby, …

Member Avatar for Narue
0
165
Member Avatar for Crazyike

Why not post the code of how you'd do it with a [FONT=Courier New]while[/FONT] loop? Then maybe your best attempt at converting it to a [FONT=Courier New]for[/FONT] loop?

Member Avatar for Narue
0
94
Member Avatar for tenoran

Code tags will preserve the spacing.[QUOTE=tenoran]Thanks for trying. But my queestion was little bit unclear. I will put the txt file and out put that I get so far.[code] txt file out put 1234 052 007 100 078 034 Id Quiz1 Quiz2 Quiz3 Quiz4 Exam 2134 090 036 090 077 …

Member Avatar for tenoran
0
135
Member Avatar for kpfannenstein

[quote]Warning W8013 line 55: Possible use of 'x2' before definition in function main() Warning W8013 line 55: Possible use of 'y2' before definition in function main() [/quote]Perhaps you want to pass [I]by reference[/I] to [FONT=Courier New]magnitude[/FONT]?[quote]Error: Unresolved external 'report1(double, int)' Error: Unresolved external 'report2(double, int, double)' [/quote]And maybe make the …

Member Avatar for Dave Sinkula
0
141
Member Avatar for compshooter

>Do you need to put the ; after the last }? No. >Do you need to put a return statement before the last }? No, but it's a good idea. >If so, what number do you put in the (), i.e. return (0), return (1), etc. Use [FONT=Courier New]0[/FONT], [FONT=Courier …

Member Avatar for vegaseat
0
153
Member Avatar for fredkwok

Do you know [U]why[/U] some [FONT=Courier New]fopen[/FONT] call failed? Using [FONT=Courier New]perror[/FONT] might give a better error message, like "no such file or directory", "permission denied", or "too many open files". But sure, you could also do something like this.[code]puts(strerror(errno));[/code]

Member Avatar for Dave Sinkula
0
74
Member Avatar for maizen
Member Avatar for Dave Sinkula
0
349
Member Avatar for klmbrt

[QUOTE=Tight_Coder_Ex][COLOR=Red]single[/COLOR], double, float, int, short, long are all type specifiers so in the example[/QUOTE]For what language(s) is single a type?

Member Avatar for Tight_Coder_Ex
1
106
Member Avatar for chanz

[QUOTE=BountyX]read [url="http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html"]http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html[/url] Unfortunetly there is a valid claim to using void main(). It's bad practice, but does; technically, follow the standard (the specific standard mentioned in that article).[/QUOTE]Been there, done that. I like [url=http://www.research.att.com/~bs/bs_faq2.html#void-main]this[/url]: [quote]Even if your compiler accepts "void main()" avoid it, or risk being considered ignorant by C …

Member Avatar for BountyX
1
233
Member Avatar for TheWorld

[FONT=Courier New]structname[/FONT] is the type. So what the compiler is telling you is that you are trying to do something akin to [FONT=Courier New][COLOR=Indigo]int = 5[/COLOR][/FONT]. You want to assign to a member of the object pointed to:[code]#include <iostream> using namespace std; struct structname { int i; }; int main(void) …

Member Avatar for Dave Sinkula
0
136
Member Avatar for Cherrio

[code] i<=J&&j<=i?cout<<"i and j equal":cout<<"i and j not equal";cout<<endl; //output 4[/code]Doesn't your compiler say something like this?[quote][FONT=Fixedsys]Undefined symbol 'J' in function main()[/FONT][/quote]Which would make it easy to find this:[code] i<=[COLOR=Red][B]J[/B][/COLOR]&&j<=i?cout<<"i and j equal":cout<<"i and j not equal";cout<<endl; //output 4[/code]

Member Avatar for Cherrio
0
114
Member Avatar for Jaron

It seems like your highlighted text would make some good Googling. STFW first. Follow up here to try to get questions to specific problems related to whichever language you choose.

Member Avatar for Dave Sinkula
0
105
Member Avatar for Lorita

[code]void getDrawers(int &numDrawers) { cout <<"Enter the number of drawers you would like."<<endl; cin >> numDrawers; } int main() { int numDrawers; getDrawers(numDrawers); // ...[/code]

Member Avatar for compshooter
0
276
Member Avatar for {{unknown}}

Aaaaaah![code]main() clrscr(); printf("\n\t\t\t Enter roll number: "); scanf("%d",&tempdata.rollno); fflush(stdin); printf("\n\t\t\t Enter Name: "); gets(tempdata.name); fflush(stdin); printf("\n\t\t\t Enter Topic: "); gets(tempdata.topic); getch();[/code]Burn the book (or teacher) you have been learning from. [U]gets()[/U][list][*][url]http://www.eskimo.com/~scs/C-faq/q12.23.html[/url] [*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044652485&id=1043284385[/url] [*][url=http://www.rsasecurity.com/rsalabs/technotes/buffer/buffer_overflow.html]buffer overflow[/url][/list] [U]fflush(stdin)[/U][list][*][url]http://www.eskimo.com/~scs/C-faq/q12.26.html[/url] [*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?id=1043284392&answer=1044873249[/url] [*][URL]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351[/URL][/list] [U]scanf()[/U][list][*][url]http://www.eskimo.com/~scs/C-faq/q12.20.html[/url] [*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044652485&id=1043284385[/url][/list] [U]clrscr()[/U][list][*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385[/url] [*][url]http://www.eskimo.com/~scs/c-faq/q19.4.html[/url][/list] You're not quite there, but let's nip this in …

Member Avatar for Dave Sinkula
0
140
Member Avatar for Khishin

Prototypes tell you the expected types, but when you call a function you don't include the type -- the type is inherently part of the variable or literal being used in the call. That is,[code]if (GetKeyState(48)==1){[/code]

Member Avatar for Narue
0
129
Member Avatar for os008
Member Avatar for mariners95

[QUOTE=mariners95]Could someone help me with a linked list code. I just cant figure it out. I dont know how to code the part where I need to insert an element in ascending order. Either when there are no nodes then when there is one or a few nodes. Can anyone …

Member Avatar for Tight_Coder_Ex
0
77
Member Avatar for Ian13

[QUOTE=Ian13]Can anyone help me with getting past this? I want it to be where you can enter another country other than the one you just looked at and it will display the data for that country too. I think that it might have something to do with variables and looping? …

Member Avatar for Dave Sinkula
0
91
Member Avatar for tommy_tucker198

[url]http://www.compilers.net/Dir/Free/Compilers/CCpp.htm[/url] [url=http://www.bloodshed.net/]Dev-C++[/url] is frequently mentioned.

Member Avatar for alsoagirl
0
183
Member Avatar for tuskyballer

Equivalent loops:[code] [B][COLOR=blue]int[/COLOR][/B] i; [COLOR=chocolate]/* * #1: while */[/COLOR] i = [COLOR=teal]0[/COLOR]; [B][COLOR=blue]while[/COLOR][/B] ( i < [COLOR=teal]10[/COLOR] ) { [COLOR=chocolate]// ...[/COLOR] ++i; } [COLOR=chocolate]/* * #2: do...while */[/COLOR] i = [COLOR=teal]0[/COLOR]; [B][COLOR=blue]do[/COLOR][/B] { [COLOR=chocolate]// ...[/COLOR] ++i; } [B][COLOR=blue]while[/COLOR][/B] ( i < [COLOR=teal]10[/COLOR] ); [COLOR=chocolate]/* * #3: for */[/COLOR] [B][COLOR=blue]for[/COLOR][/B] ( …

Member Avatar for Stack Overflow
0
715
Member Avatar for deejay400

Something akin to this?[code]#include <stdio.h> struct node { int i; char c; }; struct node list[] = { {1,'A'},{2,'B'},{3,'C'},{4,'D'},{5,'E'},{6,'F'},{7,'G'},{8,'H'},{9,'I'}, }; struct node *plist[] = { &list[0], &list[2], &list[4], &list[6], &list[8], &list[1], &list[3], &list[5], &list[7], }; int main(void) { size_t i; puts("list:"); for ( i = 0; i < sizeof list …

Member Avatar for Tight_Coder_Ex
0
106
Member Avatar for ohnbabygal

[QUOTE=Asif_NSU]The thing is that i dont create projects to do my work.[/QUOTE]You may want to investigate makefiles. Then you can use your favorite editor and still write modular code the correct way.

Member Avatar for Dave Sinkula
0
111
Member Avatar for seeplusplus

[The title does not provoke much interest or specify what you are really trying to do. Expend a little more thought for something like, "Adding and Reducing Fractions". Such things show you have thought about the problem and perhaps done some searching for related information.] With regard to reducing the …

Member Avatar for Dave Sinkula
0
119
Member Avatar for Morinar
Member Avatar for Dave Sinkula
0
134
Member Avatar for boujibabe

This is just begging to be made into an array:[code]int sale1; int sale2; int sale3; int sale4; int sale5; int sale6; int sale7; int sale8; int sale9; int sale10; int sale11; int sale12;[/code]And please use code tags.

Member Avatar for boujibabe
0
285
Member Avatar for rharvison

cin and cout are part of the standard namespace. Early on, use this:[code]using namespace std; // after the #includes[/code]Since you[code]cin >> base_cost; [/code]you shouldn't make it [FONT=Courier New]const[/FONT].[code]float base_cost = 50.00, // base cost of rental[/code]Statements end in a semicolon.[code]rental_cost = base_cost + (cost_daily * n_days)[COLOR=Blue];[/COLOR] tax = rental_cost * …

Member Avatar for rharvison
1
171
Member Avatar for dani1982

Have you looked in the [url=http://www.daniweb.com/code/code-c.html]code snippets[/url]?

Member Avatar for Dani
0
109
Member Avatar for xsxixtxhx
Member Avatar for kc0arf
0
237
Member Avatar for odee
Member Avatar for Dave Sinkula
0
121
Member Avatar for sidhjn

Here's a truth table: [url]http://www.ii.uam.es/~jlara/investigacion/ecomm/electronica/2adder.html[/url]

Member Avatar for Narue
0
147
Member Avatar for fzero

If x is 1, it won't be 2 or 3.[CODE]if (x == 1) { statement1 } else if (x == 2) { statement2 } else if (x == 3) { statement3 } else { statement4 }[/CODE]

Member Avatar for Dave Sinkula
0
90
Member Avatar for cymbalistic1

[QUOTE=cymbalistic1]I just need somebody to tell me how to export the data into Excel.[/QUOTE]Write it to a .txt file or .csv file and import it into Excel.

Member Avatar for cymbalistic1
0
101
Member Avatar for evilsilver

[QUOTE=evilsilver]yes you can asign them with =, try this[code]char *test = new char [100]; test = "this works"; [/code][/QUOTE]That's not assigning a [I]string[/I]. That's assigning a pointer (and a memory leak).

Member Avatar for jimFan
0
137
Member Avatar for tones1986

I think something like this may help.[code] if (choice == "b" || choice == "B") { cout << "Checking Balance: $" << setw(8) << setprecision(2) << fixed << checking << '\n'; cout << "Savings Balance: $" << setw(8) << setprecision(2) << fixed << savings << endl; }[/code]

Member Avatar for tones1986
0
148
Member Avatar for 40ounce68

Try adding some outputs to see what is going on. Please post a compilable sample as opposed to some fragment.

Member Avatar for Dave Sinkula
0
134
Member Avatar for dal4488

You need to terminate the following statements with semicolons:[code]const double conversion = 2.54[COLOR=Blue];[/COLOR] const int inchesPerFoot = 12[COLOR=Blue];[/COLOR][/code]And this was okay many years ago...[code]#include <iostream.h>[/code]...but if you are living in the 21st century, it should be...[code]#include <iostream>[/code]...especially since you are...[code]using namespace std;[/code]

Member Avatar for vegaseat
0
606

The End.