2,384 Posted Topics

Member Avatar for nathanj99
Member Avatar for Narue
0
211
Member Avatar for silicon

Try [FONT=Fixedsys]clock[/FONT] inistead of [FONT=Fixedsys]time[/FONT] ([FONT=Fixedsys]time[/FONT] needs only be accurate to the nearest second). [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048385167&id=1043284392[/url] Also, your may want to consider using the same seed for populating the array to compare each function. That way, each array of random numbers would be the same for each sort.

Member Avatar for Narue
0
117
Member Avatar for XxAndyxX

[code]#include <iostream> #include <vector> #include <algorithm> #include <iterator> using namespace std; vector<double> *func() { static const double init[] = {1.0,1.5,2.0,3.3}; vector<double> *vec = new vector<double>(init, init + sizeof init / sizeof *init); return vec; } int main() { vector<double> *p = func(); copy(p->begin(), p->end(), ostream_iterator<double>(cout, "\n")); return 0; } /* …

Member Avatar for Dave Sinkula
0
219
Member Avatar for Dave Sinkula

Suggestion: I like the language tags [url=http://www.gidforums.com/t-689.html]here[/url]. I've also seen them on cpp-home. Is something like this already on any wish list for Daniweb?

0
125
Member Avatar for rharvison

What do you mean by "control-break"? [url=http://en.wikipedia.org/wiki/IBM_PC_keyboard]Here[/url] it states,[quote][I]Pause/Break[/I]- CTRL-BREAK traditionally stopped programs.[/quote]I don't imagine you want to quit the program, so I could guess that you want to insert a pause. If so, just take and discard user input at the point you want, like [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1042856625&id=1043284385]this[/url].

Member Avatar for Dave Sinkula
0
242
Member Avatar for AhmedHan
Member Avatar for Dave Sinkula
0
4K
Member Avatar for mdbrock7
Member Avatar for mdbrock7
0
417
Member Avatar for JoBe

A shot into new (pun!) territory for me. [url=http://www.relisoft.com/book/tech/9new.html]Here[/url] (way down at the bottom) it states,[quote]Since placement new doesn't allocate any memory, it's an error to delete the object created by it.[/quote]For the time being I've been going with [url=http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10]this[/url] method.[quote]ADVICE: Don't use this "placement new" syntax unless you have …

Member Avatar for Fasola
0
276
Member Avatar for yacob_uk
Member Avatar for csi_a_m

Why are you trying to do the same thing twice? How about doing some [FONT=Courier New]if(file.is_open) { /* ... */ }[/FONT] around the second attempt?

Member Avatar for Dave Sinkula
0
160
Member Avatar for XxAndyxX

I can't get that far without a definition of [FONT=Courier New]account[/FONT], but your prototype doesn't match the definition.

Member Avatar for Dave Sinkula
0
175
Member Avatar for ckrieger1

>px0c0 and px0c1 are type double pointers How's your allocation of memory to px0c0 and px0c1?

Member Avatar for Fasola
0
267
Member Avatar for XxAndyxX

If you're trying to read from a file, use some function that will read from a file. Sitting at the beginning of a file and waiting for the end to come will not do much.[code]#include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ifstream …

Member Avatar for Dave Sinkula
0
9K
Member Avatar for hopeolicious

Only define [FONT=Courier New]Cars[/FONT] once.[code]struct Car { int number, miles; float gallons; float averagegallons; }[COLOR=Red]Cars[/COLOR]; Car [COLOR=Blue]Cars[/COLOR][MAXCARS];[/code]Then figure out which way to use them.[code]getdata([COLOR=Red]Cars[/COLOR].number, [COLOR=Red]Cars[/COLOR].miles, [COLOR=Red]Cars[/COLOR].gallons); putdata([COLOR=Red]Cars[/COLOR].number, [COLOR=Red]Cars[/COLOR].averagegallons);[/code]

Member Avatar for Dave Sinkula
0
156
Member Avatar for tyczj
Member Avatar for Dave Sinkula
0
177
Member Avatar for Raiders

[url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392[/url]

Member Avatar for Dave Sinkula
0
188
Member Avatar for Acidburn

This is something I'd quickly made the other day (pursuing a question in another forum, which is why it may look entirely unrelated). [code]#include <stdio.h> struct stack { size_t size; int array[5]; }; struct stack mystack; int push(int value) { printf("push(%d)\n", value); if ( mystack.size < sizeof mystack.array / sizeof …

Member Avatar for Dave Sinkula
0
167
Member Avatar for wal99d

For [FONT=Courier New]double[/FONT]s, use specifiers for [FONT=Courier New]double[/FONT]s, not [FONT=Courier New]int[/FONT]s.[code] sscanf(res,"%[COLOR=Blue]lf[/COLOR] %c %[COLOR=Blue]lf[/COLOR]",&op1,&opp,&op2); printf("%[COLOR=Blue]g[/COLOR]\n",op1); printf("%c\n",opp); printf("%[COLOR=Blue]g[/COLOR]\n",op2); printf("====\n"); printf("%[COLOR=Blue]g[/COLOR]\n",pow(op1,op2)); /* the output is for sure 2 */[/code]

Member Avatar for wal99d
0
324
Member Avatar for bluegoo06

This is not likely ever to be true.[code]*str != EOF[/code]The first loop goes to the end of file, right? Then the second loop never has anything to read, right? When do you expect to get anything different for this?[code] if (97 <= (static_cast<int>(tolower('a'))) <= 122) alphabet[static_cast<int>('a') - 97]++;[/code]That is, when …

Member Avatar for Dave Sinkula
0
175
Member Avatar for wal99d

[code]char [COLOR=Red]*[/COLOR] cmd="ls -l";[/code]This should be:[code]char cmd[COLOR=Blue][][/COLOR] = "ls -l";[/code]

Member Avatar for wal99d
0
249
Member Avatar for atrixnet

Well, your [FONT=Courier New]getstring[/FONT] returns a single [FONT=Courier New]char[/FONT] and not a [FONT=Courier New]char*[/FONT]. [code]/* grabs a string from the command prompt */ [COLOR=Red]char[/COLOR] getstring (char strquestion[255]) { /* reset */ char lineofinput[255]; if (strlen (strquestion)) printf ("%s", strquestion); fgets (lineofinput, sizeof (lineofinput), stdin); /* while we get an empty …

Member Avatar for Narue
0
619
Member Avatar for MaxC

Answer: Use [url="http://www.google.com/search?sourceid=navclient&q=cin%2Egetline"]Google[/url] to find a [url="http://www.cplusplus.com/ref/iostream/istream/getline.html"]reference[/url].

Member Avatar for azeembutt
0
283
Member Avatar for nizar4445
Member Avatar for Narue

[url=http://cboard.cprogramming.com/showthread.php?p=457428#post457428]..........[/url][QUOTE=Prelude]>C sucks Don't make me go Narue on you. ;)[/QUOTE]

Member Avatar for nanosani
0
312
Member Avatar for jhdobbins

First, I think those semicolons should be removed. [code] for (i = 1; i < cnt; i++)[COLOR=Red];[/COLOR] { for (j = 0; j < cnt - i; j++)[COLOR=Red];[/COLOR] {[/code]Second, why not throw in some debugging output statements and see for yourself? [code]#include <stdio.h> [COLOR=Blue]void show(const int *array, int cnt) { …

Member Avatar for Dave Sinkula
0
800
Member Avatar for JoBe

[QUOTE=JoBe]1) QUESTION IS: how can a pointer be NULL or 0 when it's an adress wich gives a value? Because, as I understand it to be like this: [code]Expression----------------Type--------------Value p-------------------------pointer-to-double--an adress *p------------------------double-------------(12.34)[/code] Or, is it saying that when declaring p = NULL;, the adress of that pointer is 0x00000000 and …

Member Avatar for JoBe
0
163
Member Avatar for jhdobbins

Sorry, I've just taken a cursory look.[QUOTE=jhdobbins]There is a problem with the enum file aGrade im sure but I'm not exactly sure how to fix it...[/QUOTE]Should [FONT=Courier New]tmp[/FONT] be an [FONT=Courier New]aGrade[/FONT], should [FONT=Courier New]mycourses[j+1].grades[/FONT] be a [FONT=Courier New]char[/FONT], or do you need to convert from a [FONT=Courier New]char[/FONT] to …

Member Avatar for Dave Sinkula
0
177
Member Avatar for monkeymule2

>What do these errors mean? They mean you refer to these identifiers in your code, but never define them. Perhaps they are only declared or, in the case of the constructors, are defined with different parameters.

Member Avatar for Dave Sinkula
0
132
Member Avatar for finbar

FAQ > How do I... (Level 3) > [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608]Accessing a directory and all the files within it[/url] FAQ > *nix Specific > [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047077601&id=1045780608]Working with files and directories[/url]

Member Avatar for Dave Sinkula
0
169
Member Avatar for hopeolicious

My compiler shows something similar after fixing this oddity. [code]employee.gross[COLOR=Red]ddd[/COLOR] = employee.rate * employee.hours;[/code]So the linker says it can't find these functions. Let's look at what we have.[code]void getdata([COLOR=Blue]char[/COLOR] [], int, float, int); void putdata([COLOR=Blue]char[/COLOR] [], int, float); // ... void getdata([COLOR=Red]int[/COLOR] name[], int number, float rate, int hours) { …

Member Avatar for murschech
0
126
Member Avatar for jhdobbins

[QUOTE=jhdobbins][Linker error] undefined reference to `WinMain@16'[/QUOTE]Sounds like prime keywords for a [url=http://www.daniweb.com/techtalkforums/search.php?searchid=365618]search[/url], which might turn up some [url=http://www.daniweb.com/techtalkforums/showthread.php?t=21545-WinMain%4016]relevant hits[/url].

Member Avatar for jhdobbins
0
223
Member Avatar for the b

Match each [FONT=Courier New]{[/FONT] to its [FONT=Courier New]}[/FONT]. Are you trying to do a [FONT=Courier New]do...while[/FONT] loop without the [FONT=Courier New]do[/FONT]? [code]float multiply_num(float number) { float i, j; char return_main; if(number == 0) { cout << "Enter number to multiply "; cin >> i; cout << " times "; cin …

Member Avatar for the b
0
169
Member Avatar for jeymine

> I am working on a project on playing cards using enum and class. I really need help with the function defination in this project, > Here i will attach the question, your help will be highly appreciated. You can get bac to me trough jeymineb at yahoo.co.uk. > Thanks. …

Member Avatar for marinme
0
2K
Member Avatar for JoBe

You may want to choose a different name other than [FONT=Courier New]time[/FONT], but since you are adding minutes, wouldn't it be like this?[code]mytime operator+ (int min)[/code]

Member Avatar for Narue
0
646
Member Avatar for Fasola
Member Avatar for Fasola
1
960
Member Avatar for xerxes1986

[code]ostream& operator<< (ostream& os, [COLOR=Blue]const AirborneLocation&[/COLOR] plane)[/code][code]os << "\tDistance to plane: " << [COLOR=Red]plane.distance()[/COLOR];[/code]Does [FONT=Courier New]plane.distance()[/FONT] return an [FONT=Courier New]AirborneLocation[/FONT]? Or should it be called like this?[code]os << "\tDistance to plane: " << plane;[/code]And shouldn't [FONT=Courier New]operator<<[/FONT] return [FONT=Courier New]os[/FONT]?

Member Avatar for Narue
0
177
Member Avatar for mrlucio79

[QUOTE=Narue]Accelerated C++ by Andrew Koenig and Barbara Moo[/QUOTE]Top of [thread=10232]this list[/thread]! Do you consider that list fairly accurate?

Member Avatar for Narue
0
145
Member Avatar for mikecoyner

>could anyone provide me the basic code to display "hello world" in a window? Does your compiler offer to do this for you? [URL=http://img175.echo.cx/my.php?image=hello4nk.jpg][IMG]http://img175.echo.cx/img175/5527/hello4nk.th.jpg[/IMG][/URL] >and if possible a link to the code necessary to use window api for c++ programs. Have you checked your compiler's documentation? It should be the …

Member Avatar for Narue
0
212
Member Avatar for eleet

C isn't C++, so C doesn't have constructors or the [FONT=Courier New]std::string[/FONT] type. You may get away with something like this. [code] String ExitString [COLOR=Blue]= "QUIT"[/COLOR]; /* ... */ do { PromptForGuest (inputName); } while ( [COLOR=Blue]strcmp[/COLOR](inputName, ExitString) )[COLOR=Blue];[/COLOR][/code]Personally, I don't care for the [FONT=Courier New]String[/FONT] typedef, I think it …

Member Avatar for Dave Sinkula
0
135
Member Avatar for some one

[code]float fun(float [COLOR=Red]arr[/COLOR][][1],float [COLOR=Blue]arr[/COLOR][][3]){ arr[i][5]=(arr[i][1]/arr[i][2]); return arr[i][5];}[/code]Which is who? Proper formatting such as indenting and whitespace can also make it a whole lot easier to read your own code to find mistakes.

Member Avatar for Narue
0
208
Member Avatar for banbangou

There will be ambiguity with your class and [FONT=Courier New]std::vector[/FONT] since you are [FONT=Courier New]using namespace std[/FONT].[code]struct [COLOR=Blue]vector[/COLOR] { double x; double y; friend ostream& operator<< (ostream&, [COLOR=Blue]vector[/COLOR]); }[COLOR=Red][SIZE=5];[/SIZE][/COLOR][/code]If you still want to grab the whole namespace, I think you can disambiguate like this.[code]friend ostream& operator<< (ostream&, [COLOR=Blue]::[/COLOR]vector);[/code]

Member Avatar for quickhelp
0
180
Member Avatar for Starz20

[QUOTE=Starz20]This is what I have written, but if I type in "E" to exit, it loops to enter in a number again and doesn't exit.[/QUOTE]I don't see the loop, but [FONT=Courier New]"E"[/FONT] is not a valid [FONT=Courier New]float[/FONT] number. If you want the possibility of the user input to be …

Member Avatar for Starz20
0
163
Member Avatar for nizar4445

[QUOTE=alc6379]Also, I'm sure Narue might mention this, but I know you're not supposed to use void main(). I'm not entirely sure why, and I don't want to guess, but I have an idea why. Care to elaborate further on this, Narue?[/QUOTE]I'm not Narue, but I try to be that good. …

Member Avatar for vegaseat
0
219
Member Avatar for hopeolicious

An [FONT=Courier New]int[/FONT] divided by an [FONT=Courier New]int[/FONT] results in an [FONT=Courier New]int[/FONT] using [FONT=Courier New]int[/FONT] division.[code]struct Car { [COLOR=Magenta]int[/COLOR] number, miles; [COLOR=Magenta]int[/COLOR] gallons; float averagegallons; }; /* ... */ Cars[i].averagegallons = [COLOR=Magenta]Cars[i].miles / Cars[i].gallons[/COLOR];[/code]To keep them as [FONT=Courier New]int[/FONT]s, cast one of the operands; this will cause the division …

Member Avatar for Dave Sinkula
0
178
Member Avatar for tyczj

Since choice is an [FONT=Courier New]int[/FONT], compare it with [FONT=Courier New]1[/FONT], [FONT=Courier New]2[/FONT], and [FONT=Courier New]3[/FONT] -- not with characters [FONT=Courier New]'1'[/FONT], [FONT=Courier New]'2'[/FONT], and [FONT=Courier New]'3'[/FONT].

Member Avatar for tyczj
0
114
Member Avatar for jonnie83

It sounds like you had originally specified a (GUI) Windows application, but provided code for a console application. The GUI app expects [FONT=Courier New]WinMain[/FONT], the console app expects [FONT=Courier New]main[/FONT]. It may be easiest to create a new project as a Windows Console Application, and then add your existing source …

Member Avatar for Dave Sinkula
0
308
Member Avatar for Narue

I miss this little feature: [IMG]http://img198.exs.cx/img198/6823/forumjump2fw.jpg[/IMG] It gives a bit of an "Explorer" ability. [URL=http://img205.exs.cx/my.php?loc=img205&image=devshed8sy.jpg][IMG]http://img205.exs.cx/img205/7894/devshed8sy.th.jpg[/IMG][/URL]

Member Avatar for Dani
0
343
Member Avatar for mel2005

[QUOTE=Fasola]what does -> mean, when you wrote temp->data = item; ?[/QUOTE]It is used to access a member of a class/struct/union from a pointer rather than from the object itself -- which uses the [FONT=Courier New].[/FONT] operator.[code]#include <stdio.h> struct type { int member; }; int main(void) { struct type object = …

Member Avatar for Fasola
0
359
Member Avatar for nizar4445

With the title...[QUOTE=nizar4445]Heeeeeeeeeeeeeeeeelp :cry: :cry: :cry: hello all can anybody help me pleeeeeeeeeeeeeeaaaaaaazzzzzzzzzz!!!!![/QUOTE]This generally causes a thread to be widely ignored. [QUOTE=nizar4445]Create a program that will allow the user to enter and analyse a set of data collected from an experiment. The data is to be entered by the user …

Member Avatar for Dave Sinkula
0
150
Member Avatar for rborob

I think you are ignoring what happens in the [FONT=Courier New]switch[/FONT].[code] float xCount = 0; float yCount = 0; float zCount = 0; switch( szBuf[i] ) { /* ... */ } xCount = g_pVertices[index].x; yCount = g_pVertices[index].y; zCount = g_pVertices[index].z;[/code]Before the [FONT=Courier New]switch[/FONT], you initialize them all to zero. After …

Member Avatar for Dave Sinkula
0
150

The End.