15,300 Posted Topics

Member Avatar for fishky

use [b]ofstream[/b] instead of ostream. Then include <fstream> instead of <ostream>. Finally, add using statements after the include files [code] #include <fstream> using std::ofstream; using std::ifstream; // if you want this [/code]

Member Avatar for fishky
0
1K
Member Avatar for afg_91320

Here is how to round down [code] #include <iostream> #include <cmath> using std::cout; int main() { double n = 923.45; double intpart; double fractpart = modf(n/100, &intpart); cout << intpart * 100 << "\n"; return 0; } [/code]

Member Avatar for Ancient Dragon
0
73
Member Avatar for Ancient Dragon

Is it possible to allow members to edit the text that is highlighted in yellow, such as this one in a recent thread ? The OP (and me) are just SOL if he/she doesn't like the way it turned out. And Preview Post before submitting doesn't show it either. [quote] …

Member Avatar for Dani
0
87
Member Avatar for rrreeefff

try this: [icode]printf("%03d", num);[/icode] In "%03d", the 3 means minimum of 3 digits, 0 means print 0's if num is less than 3 digits. So num = 1, that will print 001

Member Avatar for Ancient Dragon
0
97
Member Avatar for san_sarangkar

you can't because you can't stuff a whole string into a single character. If this is about some error message you got, then post the error message along with the code you wrote.

Member Avatar for stilllearning
0
169
Member Avatar for amerninja2

Why are you using wchar_t ? Its a single character, not a string, so [icode]if(com = 'deldir.') {[/icode] isn't going to compile correctly. And [b]deldir[/b] isn't a single character either, so it should be in double quotes like any other normal string literal in C/C++, not single quotes.

Member Avatar for Ancient Dragon
0
131
Member Avatar for kalku23

>>catch(std::char * s) Error most likely because there is no such thing as [b]std::char[/b]. change to this and retest: [icode]catch(const char* s)[/icode]

Member Avatar for Ancient Dragon
0
63
Member Avatar for Eirlys

Welcome to DaniWeb. >>I believe I must be the oldest member here! Not likely. See my public profile. And I know of at least one other member who is older than I am. So don't hesitate to post newbe type questions -- I still do that too.

Member Avatar for Eirlys
1
205
Member Avatar for dapcigar

1) prompt.h and prompt.cpp -- you need to specify function return values. 2) program is using uninitialized struct member in function Add_vcd(). You can fix that problem by adding a class constructor to the structure which initializes it. [code] struct vcdDB_T{ vcdRec_T vcdRecords[maxSize]; int vcdIndex; [color=red]public: vcdDB_T() {vcdIndex = 0;} …

Member Avatar for Salem
0
129
Member Avatar for number87

struct tm: is just a structure that can be use like any other structure. The localtime() function takes a time_t object and returns a pointer to a struct tm. [code] time_t now = time(0); // get current time struct tm* tm = localtime(&now); // get struct filled out cout << …

Member Avatar for sidatra79
0
1K
Member Avatar for Daco
Member Avatar for Ancient Dragon
0
186
Member Avatar for mmjack

I'm not sure what your program is attempting to do, but I do know it contains at least two memory leaks. You use [b]new[/b] operator to allocate memory to a Data pointer but never delete[] it before leaving the switch statement.

Member Avatar for Ancient Dragon
1
105
Member Avatar for Nisha Rahmat

line 61 (as shown in your post). You can not copy a character array into an int array. I guess same problem with the other lines that follow that one. line 60: >>if(factory_info[a].machine < factory_info[b].machine) You can't compare two C character arrays like that -- use strcmp() instead [icode]if( strcmp( …

Member Avatar for ahamed101
0
105
Member Avatar for Liszt

First, open the file in binary mode so that the os doesn't interpret the '\n' characters. Then you have to call seek() after each read operation. What you do with '\n' depends on what operating system you are using. *nix files just have '\n', but MS-Windolws uses '\r' and '\n', …

Member Avatar for Liszt
0
164
Member Avatar for VBNick

I'm running on 64-bit Vista Home Premium, used VC++ 2008 Express, and your program ran ok for me both in IDE and command-line. After creating a win32 windows project I used all default values except changed from UNICODE to non-UNICODE.

Member Avatar for VBNick
0
228
Member Avatar for rysin

By tradition the two arguments to main() are declared as argc and argv -- you can name them anything you wish but custom dictates those two names [icode]int main(int argc, char* argv[]) [/icode] how do you know your program returns 1? The code you posted returns 0, not 1 (see …

Member Avatar for Sci@phy
0
98
Member Avatar for kjsalk

Work through the error messages one at a time. The first error is normally what's wrong. Correct that error then recompile -- you will get a lot fewer error messages that way. For example: line #2 of the code you posted is probably wrong. System header files are enclosed in …

Member Avatar for Sci@phy
0
123
Member Avatar for Kainan54

maybe yes, and maybe no. Depends on the code and what compiler it was written with. If written with Turbo C then probably won't work with VC++.

Member Avatar for Ancient Dragon
0
158
Member Avatar for phoenix06007

[URL="http://en.wikipedia.org/wiki/Trackback"]google works wonders [/URL]:)

Member Avatar for Dani
0
94
Member Avatar for JackDurden

Here is one way it could be done. [code] class example { public: int one; int two; }; int function1(int one, int two) { return one * two; } int function2(int one, int two) { return one + two; } int main() { example number; cout<<"enter numbers"<<endl; cin>>number.one>>number.two; cout << …

Member Avatar for Ancient Dragon
0
107
Member Avatar for emotionalone

or this using FILE* [code] char iobuf[255] = {0}; while( fgets(iobuf, sizeof(iobuf), pS) ) { fprintf(iobuf); } [/code]

Member Avatar for Ancient Dragon
0
512
Member Avatar for serkan sendur

[QUOTE=Narue;710825]you can ask ten programmers to write the same program to the same specification and get ten completely different solutions.[/QUOTE] But only one correct solution -- mine :)

Member Avatar for Ancient Dragon
0
333
Member Avatar for Lardmeister

I don't normally quote scripture, but can't help it this time: "Its easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God." (Matthew 19:24) That means: I don't give a rats ass about all that much money. …

Member Avatar for sneekula
0
366
Member Avatar for nuubee

The mod operator doesn't work on doubles -- only integers. And why is mph a double? Your program isn't even using the fractional parts so you might as well make it an integer and that will solve the problem for you.

Member Avatar for Ancient Dragon
0
247
Member Avatar for NinjaLink

line 20 is in the wrong place -- move it down to line 25, when the variable search_item is known.\ [edit]^^^ he beat me to it :) [/edit]

Member Avatar for Ancient Dragon
0
194
Member Avatar for OlyComputers

Welcome to DaniWeb. And yes, its about time you get off your a** and introduce yourself to us :)

Member Avatar for Denniz
0
70
Member Avatar for Kainan54

I guess you mean you want to know about the best compiler. On Vista that would be Visual C++ 2000 (Express). There are other compilers but IMO M$ VC++ 2008 Express is the best, mainly due to its excellent debugging facilities. Most any modern c++ compiler will compile c++ code …

Member Avatar for Kainan54
0
128
Member Avatar for dhingra
Member Avatar for afromong

[code] int main() { char answer; cout << "Do you feel sexy today?"; cin >> answer; if( answer != 'Y') return 0; // exit program // now do other things } [/code]

Member Avatar for chunalt787
0
110
Member Avatar for chern4ever

The error on line 23 says variable i has not been declared. The reason is that you have to use { and } braces in the loop starting at line 19.

Member Avatar for chern4ever
0
115
Member Avatar for seogoat

start by using [URL="http://www.google.com/search?hl=en&q=c%2B%2B+stacks+tutorial&aq=f&oq="]google like this[/URL] (see the search bar at that link)

Member Avatar for dmanw100
0
105
Member Avatar for killdude69

First call [URL="http://msdn.microsoft.com/en-us/library/ms633585(VS.85).aspx"]GetWindowLongPtr[/URL] to get a pointer to its defaultProc then call CallWindowProc() when appropriate. See the GWLP_WNDPROC option.

Member Avatar for Ancient Dragon
0
249
Member Avatar for The Dude
Member Avatar for zarf

Are you combining client and server into just one program ? Or are they still two separate programs that are executed on the same machine ? >>Also how do i set a static ip address in the code because the Winsock Server requires the user to type an ip address …

Member Avatar for zarf
0
117
Member Avatar for JackDurden

you can't insert strings into int arrays, but you can insert a character [icode]pointer[a][b] = '*';[/icode] <<< single quotes, not double quotes

Member Avatar for rhoit
0
98
Member Avatar for sneekula

[QUOTE=sneekula;683008]Typical official communications between Canadians and their neighbours to the South. Americans: "Please divert your course 15 degrees to the north to avoid a collision." Canadians: "Recommend you divert YOUR course 15 degrees to the south to avoid a collision." Americans: "This is the captain of a US Navy ship. …

Member Avatar for Ene Uran
0
249
Member Avatar for mgirl

line 39 is missing close parentheses -- ) Also you need to typecast total and sum to float to prevent loss of precision. line 6: you are using uninitialized variables Your program would run a bit better (faster and efficiently) if you used [b]else if[/b].

Member Avatar for Ancient Dragon
1
91
Member Avatar for alleycot
Member Avatar for Ancient Dragon
1
266
Member Avatar for TheKebab

google for the exact error message. Often google comes up with the answer. I recall seeing something about that problem before, but you didn't post the exact error message so I can't help you. BTW: The express edition doesn't do deployments -- you will have to do it manually or …

Member Avatar for TheKebab
0
94
Member Avatar for shrikara

I'm not supprised that produces a core dump. line 10 declared a pointer that points to nowhere -- there is no memory allocated to it. If x is supposed to be an array then use malloc() to allocate memory for the array [icode]x = malloc(10 * sizeof(int));[/icode] will allocate an …

Member Avatar for kenji
0
134
Member Avatar for WongTinMing
Member Avatar for Kamal_Java

First you have to allocate memory for ebase -- you are dereferencing an unallocated pointer. So the best you can do with that is [icode]ebase = *iter;[/icode]

Member Avatar for Aashath
0
162
Member Avatar for it2051229

That is a *nix file -- if you are compiling for MS-Windows of some other os then you can't use it.

Member Avatar for Salem
0
118
Member Avatar for PaladinHammer

Don't keep the numbers as a string, but as four integers. You could enter the values in the array in sorted order but that might be a bit more difficult. [icode]int numbers[4] = {0};[/icode] After they are entered then code a sort algorithm to sort them. Or you

Member Avatar for stilllearning
0
142
Member Avatar for Ellisande

you have to pass fstream objects by reference [code] void initBoard([color=red]ifstream& [/color]board){ string squares; getline (board, squares, '\n'); cout << squares;}<------------ For testing purposes, will do other stuff l8r [/code]

Member Avatar for Ellisande
0
191
Member Avatar for charusood

See the first three answers to [URL="http://www.daniweb.com/forums/post695854.html#post695854"]your other thread here.[/URL]

Member Avatar for Ancient Dragon
0
88
Member Avatar for jie83

how about a [URL="http://msdn.microsoft.com/en-us/library/aa579858(EXCHG.80).aspx"]managed tree view [/URL]

Member Avatar for Ancient Dragon
0
151
Member Avatar for unk45

Here is an example of how you could do that [code] int main() { char origstring[] = "Once upon a time there were three little pigs."; char StringToReplace[] = "were three little pigs"; char ReplaceString[] = " was a big bad wolf."; char* ptr = strstr(origstring, StringToReplace); if( ptr != …

Member Avatar for mcriscolo
0
94
Member Avatar for Aamp88

[QUOTE=skatamatic;703589]My price is set at $250.00[/QUOTE] You work cheap :)

Member Avatar for William Hemsworth
0
141
Member Avatar for Niner710

>>Structure doesn't have restricted acces In c++ they do -- structures are nearly identical to c++ classes, except the default access type is public. TMK there are no other differences between a structure and a class.

Member Avatar for mcriscolo
0
157

The End.