2,384 Posted Topics

Member Avatar for seeplusplus
Member Avatar for Narue
0
172
Member Avatar for star320

[QUOTE=Chainsaw]That can show up if you have, say, a file name in a string and you forget to double escape the slash: "C:\Chainsaw\Kelp" // wrong "C:\\Chainsaw\\Kelp" // right[/QUOTE]Or [url=http://groups-beta.google.com/group/comp.lang.c/msg/9d3ac81f37b60ca9]use forward slashes[/url].

Member Avatar for star320
0
213
Member Avatar for os008

Now that's an impressive list of errors! Since there is no code to look at, my guess would be a missing semicolon. For example, the following will make a similar mess.[code]int x #include <stdio.h>[/code]

Member Avatar for os008
1
237
Member Avatar for odee

[QUOTE=odee]should i use [COLOR=Green]#define[/COLOR] or [COLOR=Black]const[/COLOR] in declaring constant variables?? which one is better? when should i use [COLOR=Green]#define[/COLOR] or [COLOR=Black]const[/COLOR]? for example when i declare a hexadecimal (0x01), should i use [COLOR=Green]#define [/COLOR]or [COLOR=Black]const[/COLOR]?[/QUOTE]It depends. A constant variable will take up space, and finding its value may take more …

Member Avatar for odee
0
202
Member Avatar for F50

Try this:[code][COLOR=Green]int [/COLOR]main() { // EventPtr event_queue; Event *eventPtr; eventPtr = new Event[MAX_EVENTS]; [COLOR=Indigo]eventPtr[/COLOR][0][COLOR=Blue].[/COLOR]event_type = 1; [COLOR=Indigo]eventPtr[/COLOR][0][COLOR=Blue].[/COLOR]time_value = 2; [COLOR=Indigo]eventPtr[/COLOR][0][COLOR=Blue].[/COLOR]bus_num = 0; [COLOR=Indigo]eventPtr[/COLOR][0][COLOR=Blue].[/COLOR]bus_stop = 1; [COLOR=Green]return 0;[/COLOR] }[/code]

Member Avatar for Intel
0
193
Member Avatar for seeplusplus

[QUOTE=murschech]For starters, you'll need 2 constructors. One will be something like [code]rational(int m, int n) { num = m; den = n; //You really should check for n == 0 }[/code]and the other (the default) would be[code]rational() { num = 0; den = 1; }[/code][/QUOTE]This could also be done like …

Member Avatar for Dave Sinkula
0
89
Member Avatar for hopeolicious

>How would I find the highest salary salesperson of a list of salespersons The same way you find the largest value in an array.

Member Avatar for Dave Sinkula
0
92
Member Avatar for firebird
Member Avatar for Dave Sinkula
0
102
Member Avatar for Guppy25

[code]char Fraction::slash=[COLOR=Red]"[/COLOR]/[COLOR=Red]"[/COLOR];[/code]This should be:[code]char Fraction::slash=[COLOR=Blue]'[/COLOR]/[COLOR=Blue]'[/COLOR];[/code]

Member Avatar for Dave Sinkula
0
117
Member Avatar for Sukiebaby

[QUOTE]I am having a problem getting the execution screen to stay in order for me to view the program. Can someone tell me what is wrong with my program please?[/QUOTE] Nothing is "wrong". [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385"]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url]

Member Avatar for evilsilver
0
249
Member Avatar for hopeolicious

[quote]I have to write a program to read N data items into two arrays, X and Y, of size 25.[/quote]Surely you can translate that into code.[code]int X[25]; int Y[25];[/code][quote]Calculate and store the products of corresponding pairs of elements of X and Y in a third array, Z, also of size …

Member Avatar for Dave Sinkula
0
110
Member Avatar for joejoenyc718

Being a math major, you probably don't need to be told that the average will be the [FONT=Courier New][I]sum[/I][/FONT] divided by the [FONT=Courier New][I]count[/I][/FONT]. [Heavy hinting for possible variable names here.] Entering a single number might be done like this.[code] int number; cout << "Enter a number: "; cin >> …

Member Avatar for Khishin
0
141
Member Avatar for seeplusplus

[QUOTE=seeplusplus]i have a problem with this code, my cin statement is only reading in one character i think, how do i fix this?[/QUOTE]Don't ask it to read only one character. (And read some of the other responses above.) (And please make an attempt at a fix!) (And please learn to …

Member Avatar for Dave Sinkula
0
153
Member Avatar for QTpie

Dividing by zero?[code]if ( ([COLOR=Blue]A=0[/COLOR])||(((B*B-4*A*C))<=0) );[/code]This assigns 0 to A. Doesn't your compiler give you a warning?

Member Avatar for Dave Sinkula
0
266
Member Avatar for ellas747

How would you express the addition of two complex numbers without code? Then try to translate that into code. (And keep in mind what you intend to do: add to the current object, or add two distinct objects and return a third.) [And you can edit your post to add …

Member Avatar for 1o0oBhP
0
156
Member Avatar for dallin

[QUOTE=vegaseat]Test drive this to get another hint: [php]// pad with zero using sprintf() #include <stdio.h> int main() { int mile; //, foot, inch; char *pad; printf("Enter miles: "); scanf("%d", &mile); fflush(stdin); // flush input stream // pad with max 3 zeros (this is a zero not an ohh) sprintf(pad,"%03d",num); printf("Zero …

Member Avatar for Dave Sinkula
0
111
Member Avatar for migthyjohn

Your editor appears to have used [COLOR=Red]“[/COLOR]fancy[COLOR=Red]

Member Avatar for migthyjohn
0
107
Member Avatar for dallin

[QUOTE=Acidburn]abs function is for doubles...fabs is for floats[/QUOTE]No. Care to try again?

Member Avatar for Acidburn
0
98
Member Avatar for allomeen

Yes, you are trying to write to read-only memory. Create an array with enough space instead of trying to write to a string literal initializer. [edit][code]#include <stdio.h> #include <string.h> int main( void ) { char user[] = "name"; char temp[ sizeof user + 5 ] = "USER "; strcat(temp, user); …

Member Avatar for Dave Sinkula
0
144
Member Avatar for akila

Perhaps something like this: [url]http://www.eskimo.com/~scs/C-faq/q14.5.html[/url] [code]#include <stdio.h> #include <math.h> int main(void) { float a = 1.0F, epsilon = 1.19209e-07F; while ( (float)fabs(a) > epsilon ) { printf("a = %g\n", a); a /= 2.0f; } return 0; } /* my output a = 1 a = 0.5 a = 0.25 a …

Member Avatar for murschech
0
154
Member Avatar for cameronius

[code] char* value; [/code]Where is the part that you have this pointer point to memory you can write to?[code] value += int(passkey[x]); [/code]Can you describe in words what you believe this is doing?[code] num_value = atol (value); [/code]Since [FONT=Courier New]atol[/FONT] requires a null-terminated string, where do you null terminate the …

Member Avatar for Siersan
0
293
Member Avatar for crq

[QUOTE=murschech]My question was what are the first two lines about. I was told that their purpose was to avoid mutiple compilations.[/QUOTE]Perhaps you remember it wrong -- was it to "[post=81677]prevent multiple [I]inclusion[/I][/post]"?

Member Avatar for Dave Sinkula
0
162
Member Avatar for akila

Would some adaptations of [url=http://www.daniweb.com/code/snippet149.html]this[/url] be helpful?[code]#include <stdio.h> #include <limits.h> char *bits_uchar ( char *dest, unsigned char value ) { char *start = dest; unsigned char bit; for ( bit = 1 << (CHAR_BIT - 1); bit > 0; bit >>= 1 ) { *dest++ = value & bit ? …

Member Avatar for Dave Sinkula
0
203
Member Avatar for dallin

Promote one of the operands to [FONT=Courier New]double[/FONT].[code] int a = 9, b = 12; double d = [COLOR=Blue](double)[/COLOR]a / b;[/code]

Member Avatar for dallin
0
162
Member Avatar for ysong00

This string is 7 characters long (it ends with a null terminator):[code]".-..-."[/code]By declaring the second dimension the wrong size, your string has no null terminator and consectutive strings run together.

Member Avatar for vegaseat
0
96
Member Avatar for kloony
Member Avatar for Narue
0
120
Member Avatar for mad_cow01

[code]/* triangle.h */ #ifndef TRIANGLE_H #define TRIANGLE_H struct triangle { double base, height; }; #endif[/code]

Member Avatar for 1o0oBhP
0
129
Member Avatar for Kate

Try something along this line:[code]#include <fstream> #include <cstdio> using namespace std; int main() { char filename [ FILENAME_MAX ]; for ( int i = 1; i <= 5; ++i ) { [COLOR=Blue]sprintf(filename, "%d.txt", i);[/COLOR] ifstream file(filename); // ... } return 0; }[/code]

Member Avatar for Chainsaw
0
323
Member Avatar for compeat

[QUOTE=compeat]hi! I have a problem about "[B]range of data types[/B] ".I work on program that require long digits .in "boland c++ 5.2 's help" range of long is [B]4294967295[/B] . but why this sample program doesn't work??!! [CODE] int main(){ long a=4294967295,b; b=a; return 0; }[/CODE] CAN YOU HELP ME? …

Member Avatar for Dave Sinkula
0
563
Member Avatar for mr_mooz

[QUOTE=mr_mooz]So how can I get round that? when i use just & or | i get an error.[/QUOTE]You want to bitwise AND or bitwise OR two floating point values? The result may not be a number even if you were able to combine the bits of each object.

Member Avatar for Dave Sinkula
0
212
Member Avatar for sid3ways s13

[QUOTE=sid3ways s13]I'm on my second assignment now which I have to write a program that will ask the user for one of three choices. for example: Press c to calculate the area of a circle, t for a triangle, r for a rectangle, or q for quit. Then the program …

Member Avatar for alc6379
1
956
Member Avatar for seeplusplus

[QUOTE=seeplusplus]alright, say i enter a 1,2,3 when my program asks me, when im printing out the contents of the pointers in the function order_chars, it prints 1,2,1....instead it should print 3,2,1....cause the function reorders the characters i entered around. heres my code, can you see the problem?[/QUOTE][code]order_chars ( c3ptr, c2ptr, …

Member Avatar for Chainsaw
0
143
Member Avatar for cutenature

Only return [FONT=Courier New]ptr[/FONT] from the function. Only [FONT=Courier New]strcpy[/FONT] a valid string to [FONT=Courier New]ptr[/FONT] (if it is non-[FONT=Courier New]NULL[/FONT]).

Member Avatar for Chainsaw
0
102
Member Avatar for JoBe

The [B][FONT=Courier New]break;[/FONT][/B] will only break the innermost loop.[code]#include <iostream> #include <cstddef> using namespace std; int main ( void ) { int array [ 10 ]; size_t i, j; for ( i = 0; i < sizeof array / sizeof *array; ++i ) { cout << "? "; cin >> …

Member Avatar for JoBe
0
854
Member Avatar for knight81

It is likely that you should be using the standard header [FONT=Courier New]<stdlib.h>[/FONT].

Member Avatar for knight81
0
151
Member Avatar for jmj8@duke.edu

[url]http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.8[/url] [thread]16201[/thread]

Member Avatar for jmj8@duke.edu
0
77
Member Avatar for giedz86
Member Avatar for xxraveteddyxx

[URL=http://www.google.com/search?q=free+c%23%2Fc%2B%2B compiler]Google[/URL] or [url]http://www.compilers.net/[/url] come to mind.

Member Avatar for Dave Sinkula
0
206
Member Avatar for niamul
Member Avatar for blackhawk

[QUOTE=blackhawk]There is no support for the inport and outport functions in borland C++ win32. Are there any alternative functions avaliable.[/QUOTE]You may want to check out WinIO, which can be found [url=http://www.internals.com/]here[/url].

Member Avatar for Dave Sinkula
0
183
Member Avatar for saloo

Please read the [url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]Announcement[/url].

Member Avatar for alc6379
0
75
Member Avatar for zack_rage

[QUOTE=zack_rage]when i run or compile basic programs that i have made it says a error message the stdio.h is not found so that the program has no output [/QUOTE]It sounds like you haven't told the compiler where to find the headers. [QUOTE=zack_rage]any good compilers that can you recommend or tips …

Member Avatar for murschech
0
102
Member Avatar for Tester2

Exactly 1 [FONT=Courier New]delete[/FONT] for every [FONT=Courier New]new[/FONT]?[code]struct movies { char title[10]; int year; }; int main() { movies *films = new movies; // use films delete films; return 0; }[/code]Or [I]don't[/I] use [FONT=Courier New]delete[/FONT] and don't use [FONT=Courier New]new[/FONT]?[code]struct movies { char title[10]; int year; }; int main() { …

Member Avatar for Tester2
0
179
Member Avatar for ispep

Is this what you are asking? [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392[/url]

Member Avatar for Dave Sinkula
0
83
Member Avatar for galmca

[QUOTE=galmca]i have tried everything[/QUOTE]But you forgot to copy and paste these attempts that we may correct them and instead assume that someone will drop in your lap exactly the code you are thinking of.

Member Avatar for Narue
0
120
Member Avatar for Acidburn

Neither. An array of [FONT=Courier New]char[/FONT] that ends with a terminating null byte is a c-style string. A single char thus can never be a string. And an uninitialized [FONT=Courier New]char data[];[/FONT] is an incomplete type. And [FONT=Courier New]'operator<<' not implemented in type 'istream' for arguments of type 'char *'[/FONT].

Member Avatar for geeeez
0
140
Member Avatar for goforit

Worthwhile reading:[list][*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043372399&id=1043284385[/url] [*][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044652485&id=1043284385[/url][/list]

Member Avatar for Narue
0
182
Member Avatar for Programmer88

From a quick glance, I'd guess it might be related to the missing breaks for each case. Would you mind describing the error?

Member Avatar for Programmer88
0
178
Member Avatar for murschech

It prevents multiple inclusion of the header. That is, on a second attempt to [FONT=Courier New]#include "add.h"[/FONT], [FONT=Courier New]ADD_H[/FONT] would already be defined and thus the entire [FONT=Courier New]#ifndef[/FONT] block would be skipped.

Member Avatar for Dave Sinkula
0
109
Member Avatar for kellyandtopher

Try compiling and running the code you are developing.[code]#include<[COLOR=Red]iostream[/COLOR]> [COLOR=Red]using namespace std;[/COLOR] void my_sum(int r) { float sum; sum = 2 * 3.14 * r; cout << "The circumference of a circle is " << sum << "." << endl; } int main() { [COLOR=Red]my_sum(1); return 0; }[/COLOR][/code]

Member Avatar for frrossk
0
122

The End.