5,237 Posted Topics
Re: > 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 … | |
Re: > 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
![]() | |
Re: > 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] … | |
Re: 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] | |
Re: [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) … | |
Re: > 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? | |
Re: 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 … | |
Re: 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() { … | |
Re: 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. | |
Re: There goes another annoyance. <fx: turns off the show sig line to hide the pointless horizontal scroll> | |
Re: > 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 … | |
Re: [url]http://catb.org/~esr/faqs/smart-questions.html#urgent[/url] | |
Re: You're compiling on a windows box, and windows doesn't do pipe's. I've no idea what port() is. | |
Re: 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". | |
Re: 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] | |
Re: Buy a musical instrument, then either blow into it, hit it with some object or pluck away at the strings (as appropriate). | |
Re: 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. | |
Re: Have you come across the [URL="http://www.sgi.com/tech/stl/set.html"]STL[/URL] yet? | |
Re: 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? | |
Re: 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. | |
Re: > [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). | |
Re: 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[]) { … | |
Re: This is all I have to say about the topic title. [url]http://catb.org/~esr/faqs/smart-questions.html#urgent[/url] | |
Re: Is it [URL="http://www.darwinawards.com/"]Darwin[/URL] time again? | |
Re: [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. | |
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. … | |
Re: > 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 ; … | |
Re: > 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. | |
Re: [url]http://catb.org/~esr/faqs/smart-questions.html#urgent[/url] | |
![]() | |
Re: strtod() would be a better function to use, because it has better error diagnostics. | |
Re: 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] | |
Re: It would be better IMO to actually learn ANSI-C. K&R C is strictly historical or for old code requiring long term maintenance. | |
Re: 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 … | |
Re: > 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 … | |
Re: 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). | |
Re: 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? | |
![]() | Re: > 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 … |
Re: > 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. | |
Re: PI/180 turns degrees into radians. But since they're already in radians, don't you want to do the inverse of this? | |
Re: sourceforge has more code than you can shake a stick at. How much of it would be considered good learning material is another matter. | |
Re: [url]http://clusty.com/search?query=big+o+complexity&sourceid=Mozilla-search[/url] | |
Re: > 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 … | |
Re: Which operating system and compiler are you using? |
The End.