5,237 Posted Topics

Member Avatar for MidiMagic

> Pot users want pot legalized. Alcohol already is legal, and causes vastly more damage on a weekly basis all around the planet. As well as demonstrating that most people inherit the "stupid" gene from both parents, alcohol also makes them loud and abusive in the process. For the older …

Member Avatar for Ezzaral
0
388
Member Avatar for #include_rose

> That's weird because my program is working even without doing it Seems to me that you're compiling your C code with a C++ compiler then. Try renaming your prog.cpp file to be prog.c then see what happens.

Member Avatar for #include_rose
0
295
Member Avatar for Slate2006

Did you search for previous answers to this common problem? > I am totally lost and need some help. I'm going to assume that you've successfully completed some previous assignment, and that the idea of being "totally" lost is an exaggeration. For example, could you write a program which printed …

Member Avatar for Etniespr101
0
86
Member Avatar for winky

1. main returns an int - no ifs buts or maybes. 2. bool compact(void); But where is the code to do this? You have to write the implementation as well. > Also, if you guys could let me know how to add line numbers to my code that would be …

Member Avatar for winky
0
189
Member Avatar for Ryen_Lee

Lemme get this straight, you want to purposely cripple your machine so that no matter how much work you have to do, it will always take twice as long to do it. Or are you asking why your program which contains "while(1)" is burning all the CPU time and you …

Member Avatar for Ancient Dragon
0
105
Member Avatar for RohitSahni

On the face of it, it would seem that you're passing a pointer to a function (which is a C++ function), to a C function (pthread_create) which expects a pointer to a C function. Put [INLINECODE]extern "C"[/INLINECODE] in front of the prototype/declaration of the function you want to run as …

Member Avatar for Salem
0
189
Member Avatar for iamthwee
Member Avatar for mank

> a[] can not use pointer arithmetic like you do with *a so they are not interchangeable. In the context of being a parameter to a function, they are equivalent. [code] void foo ( int a[] ) { a++; } void bar ( int *a ) { a++; } [/code] …

Member Avatar for mank
1
2K
Member Avatar for dukedoc

Start with [INLINECODE]std::map<std::string, Commands> table;[/INLINECODE] Then add your translation information, like [INLINECODE]table["model"] = MODEL;[/INLINECODE] Then you can have say [code=c++]std::string command = "model"; // or as read from the file switch ( table[command] ) { case MODEL: // and so on }[/code]

Member Avatar for Salem
0
236
Member Avatar for hotice187

[URL="http://catb.org/~esr/faqs/smart-questions.html#writewell"]http://catb.org/~esr/faqs/smart-questions.html#writewell[/URL] It's just a 1D array. Look up the comma operator in your book. > hi I use Turbo C compiler in my school (Gujarat, India) If India ever wants to catch up with the rest of the world, they really need to start teaching students with modern (ie ANSI) …

Member Avatar for Salem
0
105
Member Avatar for perl21

> I am trying to write a program that reads the keyboard input while running in the background. This seems to be a very non-trivial program for someone who is "new". Are you sure of your specification?

Member Avatar for Salem
0
94
Member Avatar for aus_fas1

Being able to indent code would be a start. Does what you posted look like what you see in your IDE? If not, then think about it and don't just copy/paste and press submit. FYI, never mix spaces and tabs for indenting. Everything interprets tabs differently, so the result is …

Member Avatar for Lerner
0
99
Member Avatar for the.alchemist

Assuming the ; is a typo (it won't even compile), then it seems fine here (cygwin/gcc) [code] #include <stdio.h> #include <string.h> #include <stdlib.h> struct settings { char setting[40][255]; }; void changeSetting(struct settings *tempSettings, char *newValue, int indexValue) { if (indexValue < 40) { strcpy(tempSettings->setting[indexValue], newValue); } } int main() { …

Member Avatar for Salem
1
115
Member Avatar for crunchycrisp

Perhaps you can work on indenting your code as well. It's so bad that I'm not going to look at it, and I suspect that you're finding it hard to follow the flow of it in your editor as well.

Member Avatar for Aia
1
154
Member Avatar for Ancient Dragon

There goes another annoyance. <fx: turns off the show sig line to hide the pointless horizontal scroll>

Member Avatar for Ancient Dragon
1
62
Member Avatar for sarwar

> after that "pthread_create" method return status code 12. Which if you look up in errno.h, or print using perror(), you would find out why. [code] iret1 = pthread_create( &thread1, NULL, runModule, (void*) &t_data); if ( iret1 != 0 ) { printf( "Tread Create failed:%s\n", strerror(iret1) ); } [/code] The …

Member Avatar for Salem
0
178
Member Avatar for cmoodc
Member Avatar for Barefootsanders

You're compiling on a windows box, and windows doesn't do pipe's. I've no idea what port() is.

Member Avatar for Duoas
0
316
Member Avatar for The Dude

At least GE scales properly. I was shocked to see such a site with that kind of reputation take such liberties with it's non-linear scaling of maps to fit the "globe".

Member Avatar for lasher511
0
94
Member Avatar for AnthIste

Examples [code=c++] int numbers[4][2]; int (*p)[2] = numbers; (*p)[0] = 0; // numbers[0][0] = 0; p++; // move to next row (*p)[0] = 0; // numbers[1][0] = 0; [/code]

Member Avatar for AnthIste
0
116
Member Avatar for CornPoper

Buy a musical instrument, then either blow into it, hit it with some object or pluck away at the strings (as appropriate).

Member Avatar for Ancient Dragon
0
83
Member Avatar for mypopope

But using C-style strings and strcmp() in a C++ program just sucks when a perfectly reasonable [URL="http://www.daniweb.com/forums/post420059-4.html"]solution [/URL]using std::string has already been posted. Yes you can use == when you're using a std::string.

Member Avatar for WaltP
0
239
Member Avatar for still_learning

Have you come across the [URL="http://www.sgi.com/tech/stl/set.html"]STL[/URL] yet?

Member Avatar for tracethepath
0
109
Member Avatar for dddave999

Let's see, you chose to ask "which is the best language" in a C++ forum. Are you going to listen to any answer which isn't "use C++" ? Or let me put this another way, do you already know C++ in any shape or form?

Member Avatar for dddave999
0
335
Member Avatar for mister-fett

Well despite their C++ skills, there's already one glaring security hole just waiting to be exploited. Writing internet facing applications needs a lot more security awareness than this. Using languages which protect you from dumb stuff like unguarded reads into finite length char arrays for example.

Member Avatar for WaltP
0
432
Member Avatar for weasel7711

> [INLINECODE]int elemNum = (sizeof(*someArray)/sizeof(someArray));[/INLINECODE] 1. It's [INLINECODE]size_t elemNum = (sizeof(someArray)/sizeof(*someArray));[/INLINECODE] 2. It only works when the array itself is in scope. You can't pass the array to a function (it decays to just a pointer, and all the size information is lost).

Member Avatar for weasel7711
0
2K
Member Avatar for warpstar

It only works because "pointer to whole array - which is [INLINECODE]&array[/INLINECODE]" and "pointer to first element of array - which is just [INLINECODE]array[/INLINECODE]" happen to have the same value. The value may be the same, but you're playing with fire with the types. [code]int main(int argc, char* argv[]) { …

Member Avatar for Salem
0
486
Member Avatar for warpstar

This is all I have to say about the topic title. [url]http://catb.org/~esr/faqs/smart-questions.html#urgent[/url]

Member Avatar for Salem
0
157
Member Avatar for The Dude

Is it [URL="http://www.darwinawards.com/"]Darwin[/URL] time again?

Member Avatar for jasimp
0
281
Member Avatar for warpstar

[url]http://c-faq.com/malloc/calloc.html[/url] Note in particular that using calloc to initialise your floats to 0.0 is NOT portable. Also, since this is C++, you should really be using [INLINECODE]p = new float[n];[/INLINECODE] If this were a C program, I would be telling you NOT to cast the result of malloc.

Member Avatar for Salem
0
221
Member Avatar for Salem

Starting from [URL="http://www.daniweb.com/forums/forum2.html"]here [/URL], I searched for "accident" and got this (saved) [URL="http://www.daniweb.com/forums/search867656.html"]list [/URL]. What is fairly obvious is that this [URL="http://www.daniweb.com/forums/thread93948.html"]thread[/URL] is not in that list. Why isn't the search finding this recently added thread containing the search term? What is also obvious is that the results are unsorted. …

Member Avatar for Dani
0
181
Member Avatar for Duki

> I can't get it to work with numbers >=12; it gives a system error that it failed unexpectedly. 1. You don't free the memory you allocate. Eventually, you'll run out of memory. 2. You run off the end of the memory allocated. [INLINECODE]for ( int i = 2 ; …

Member Avatar for Duki
0
758
Member Avatar for warpstar

> since its not returning anything? Well it needs to return something, because there is an assignment here. kptr = function2( n ) ; And it needs to return int* (not int), because that's the type of kptr.

Member Avatar for WaltP
0
121
Member Avatar for zayalaksme
Member Avatar for Salem
0
70
Member Avatar for thunderstorm98
Member Avatar for mank

strtod() would be a better function to use, because it has better error diagnostics.

Member Avatar for Salem
0
119
Member Avatar for profess69

Split from the dead thread [url]http://www.daniweb.com/techtalkforums/thread52372.html[/url] Also, read this [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url]

Member Avatar for Ancient Dragon
0
335
Member Avatar for fcleme

It would be better IMO to actually learn ANSI-C. K&R C is strictly historical or for old code requiring long term maintenance.

Member Avatar for Ancient Dragon
0
137
Member Avatar for koolboy

Read [URL="http://www.daniweb.com/forums/announcement8-3.html"]this [/URL]before you ever think about posting more code. Do you think the mods have nothing better to do all day than clear up after you? Examples: Last edited by stymiee : 1 Day Ago at 18:02. Reason: added code tags Last edited by Ancient Dragon : 8 Days …

Member Avatar for Ancient Dragon
-1
136
Member Avatar for guaild

> The program is in C++ (Borland C++ 3.1, old history!). Then you're stuck, because all you can create are DOS programs. If you want something smarter, you need to create a proper win32 service, and for that you'll need a compiler more in tune to the operating system you're …

Member Avatar for guaild
0
321
Member Avatar for JavaGuy147

If your debt grows quicker than the min repayment can reduce it, then it will grow and grow until it reaches infinity (which is what #INF means).

Member Avatar for Ancient Dragon
1
244
Member Avatar for step2stepgirl

It seems fairly well explained as it is. What more do you need? A for loop to iterate over the members of the vector perhaps?

Member Avatar for Duoas
0
75
Member Avatar for susuoi

> To make the computation faster, I found fork command. But only if you're running on a machine with more than one physical processor. If not, you're just thrashing the scheduler. Oh, and check out the range of "read this first" posts at the top of the forum to learn …

Member Avatar for Salem
0
82
Member Avatar for mickinator
Member Avatar for Jobe007

> for (a>6;a<=i;a++); //Execution of the series > if (a%2!=0); // calculating the odd numbers The trailing ; on both these lines is a huge problem. Next time, use [cod[b][/b]e][/code] tags around your code.

Member Avatar for WaltP
0
117
Member Avatar for prushik

PI/180 turns degrees into radians. But since they're already in radians, don't you want to do the inverse of this?

Member Avatar for prushik
0
171
Member Avatar for wilhelm08

sourceforge has more code than you can shake a stick at. How much of it would be considered good learning material is another matter.

Member Avatar for Salem
0
102
Member Avatar for anju24

[url]http://clusty.com/search?query=big+o+complexity&sourceid=Mozilla-search[/url]

Member Avatar for Ptolemy
0
106
Member Avatar for aus_fas1

> Remember, read_dist is a pointer to double. Funny, it looked like an array to me. > Second. the sizeof requires parentheses. Wrong again, it only needs () when it's a variable name, not a type name. Go back to your original code fmufti > fileout.write((char *) dist, sizeof(dist[0])*ArraySize); //size …

Member Avatar for aus_fas1
0
249
Member Avatar for addicted

The End.