1,494 Posted Topics
Re: Technically speaking, the only difference between code and data are memory attributes. So an array could carry values that equate to a function calls but you could not call them unless you changed the memory attributes to read/execute and pointed the instruction pointer at them.. | |
Re: This is how I would solve this problem [code] #include <iostream> class BaseClass { public: BaseClass( ){ } ~BaseClass( ){ } double getitsvalue() const { return value; } void setitsvalue(double val) { value = val; } protected: double value; }; class DerivedClass : public BaseClass { public: DerivedClass( ) { … | |
Re: Nothing, you are constructing not assigning. | |
Re: [QUOTE=VIKRAM KARKI;1487744]hi im vikram my question is WEATHER A NULL CHARACTER OCCUPY ANY SPACE IN MEMORY IF YES THAN HOW MUCH SPACE IT NEEDED?[/QUOTE] Why are you resurrecting an old thread(Oct 4th, 2008) and why the CAPS? | |
Re: A make file is just a list of instructions for the compiler and linker. If your interested try googling make file tutorial or check here [url]http://mrbook.org/tutorials/make/[/url] | |
Re: You actually got this to compile with a C compiler? How did you manage that? Your structure and array of structures should be set up like below. [code] struct menuItemType { char *menuItem; double menuPrice; }; struct menuItemType order[10] = { {"Plain Egg",2.50}, {"Bacon and Egg",3.45}, {"Muffin",2.20}, {"French Toast",2.95}, {"Fruit … | |
Re: Any memory that you allocate should be also freed and since your returning a pointer to the allocated memory, you can use that to free it. Also, why all the comments its really distracting. | |
Re: Use the function fgets(). char *fgets(char *s, int size, FILE *stream); | |
Re: Because j is a local variable it takes whatever value that happens to be on the stack...To fix this initialize j to 0 [code] int j = 0; [/code] | |
Re: A multi-thread program that's shares common data amongst the threads can run bug free on a single core CPU but fail on a multi-core CPU..How do you correct this situation? You anticipate and correct the possibility of two or more threads writing/reading common data by using a mutex or semaphore. | |
Re: You should mark this a solved. | |
Re: You could use [code] buf = const_cast<char*>(ConstBuffer); [/code] but using a cast to get your code to work is a good indicator of poorly written code. | |
Re: Make the data member public. | |
Re: Try this [code] double sum = accumulate(a.begin(),a.end(),0.0); [/code] | |
![]() | Re: I'm not sure what C compiler your using but you should use one that's modern.. these lines are wrong [code] read(clientFd,lowerLimit); read(clientFd,upperLimit); write(clientFd,sumOfPrimes(lowerLimit,upperLimit)); [/code] ssize_t read(int fd, void *buf, size_t count); ssize_t write(int fd, const void *buf, size_t count); Please note the number of arguments. |
Re: If I was attacking this problem I would create two functions. The first one would find the starting position and the second one would be my recursive function. Also, will the path through the array have loops in it? | |
Re: First hint: create an enumerated set like below [code] enum Direction {Left, Right, Top, Bottom}; [/code] Use these values to inform the recursive function where its being called from. This keeps the direction moving down the path and not doubling back. | |
Re: [QUOTE=Dexxta27;1479386]why do you use call input twice, using the increment?[/QUOTE] He's showing you two equivalent ways of doing the same thing. | |
Re: The GCC compiler has this option built in, just compile with this option -ftime-report example: g++ filename.cpp -ftime-report -o filename | |
Re: Line 34 should be [code] writeRes = write(fd_out,genBuffer,bufsize); [/code] | |
Re: I found this link, it explains how to create a dll with mingw and if you scroll down to the bottom of the page you'll find a link for calling your dll from C#. [url]http://www.adp-gmbh.ch/win/misc/mingw/dll.html[/url] | |
Re: You might also want to do something if the guess is too high, too low or correct. example: you enter a random number say => 765 The computer guesses 500 which is too low so the next number is one half of the high range => 750...and this continues, taking … | |
Re: Try changing line 13 to [code] while(input != "done\n") [/code] | |
Re: Your going about this the wrong way, to initialize an array you must access each element..Like so [code] #include<iostream> #include <vector> using namespace std; int main() { double l1=25.0, l2=5.0, l3=20.0, l4=10.0, x1; int array1[13]; int i = 0; for(x1=0.0; x1<361.0; x1+=30.0) { array1[i++] = x1; } for(i = 0; … | |
Re: You have a couple of problems in your code. You should call the pow() like this [code] S=pow(M/I, M*Y); [/code] result is used uninitialized here [code] S = result + 1 * D; [/code] | |
Re: Can you do it? Yes, its just a matter of building a string or strings containing the the compiler name and proper switches plus the files in question and then calling system(created_string). | |
Re: Please use code tags and proper formating. The problem, don't define your function inside of main. | |
Re: [QUOTE=spoonlicker;1477846]I'm not. I'm seriously waiting for an answer. It's not wasting peoples' time if they are supposedly here to help.[/QUOTE] You do realize that an 'equivalent' value can be represented as a integer, octal, hexadecimal or binary...You realize that right? So you can write raw machine code with a hex … | |
Re: The container list has a merge member function, I would look up its functionality. [url]http://www.cplusplus.com/reference/stl/list/merge/[/url] | |
Re: You can't allocate memory to the end of your array. You must allocate the new memory and then copy the existing array into the new memory and then finally delete the old memory. | |
Re: If the poster will search this section, he'll find a post that shows how to randomly fill an array with unique values...The post was recent(1 - 7 days ago). | |
Re: I didn't look over your code because its not enclosed within code tags. However have you considered that your program does not run continuously since its scheduled ran and rescheduled again. | |
Re: In C++ you generally create the variables where they are used...In C its considered improper programming style to mixed declarations and code but C++ its O.K. | |
Re: Line 26 [code] serv_addr.sin_addr.s_addr = INADDR_ANY; [/code] Should be [code] serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); [/code] If that fails then try a larger port number like 50000. | |
Re: [QUOTE=jephthah;606438]on the one hand i probably complain too much. on the other hand, after a long day at work, i find this coding style with no whitespace, no indentions, no syntax, no nothing, to be unreadable in the most annoying way. anyhow, sockaddr and sockaddr_in are two different structure types. … | |
Re: I just ran your code and your missing 3, 5, 7. I think this works...Never checked it with valid prime numbers. [code] #include<stdio.h> #define ARR_SIZE 100 int main() { int arr[ARR_SIZE], i, j = 1, left; for(i = 0;i < ARR_SIZE; ++i) { arr[i] = j++; } for(j = 2; … | |
Re: Line 80 [code] linked_list_push_back(11, 99); [/code] Your passing the number eleven not your linked list pointer ll. | |
Re: First question. Do you want to display it reversed or do you what to reverse the order in the c string? | |
Re: [QUOTE=hariharan89;1475608] I didnt understand, what will be stored in myargv? could any one tell me what will be the final value of argv? thanks in advance ..[/QUOTE] What's stored? A double pointer to char, would it make more sense written like this [code] char **myargv = &argv[1]; [/code] What's the … | |
Re: Line 24 [code] *chptr='\0'; [/code] Is chptr pointing to valid memory? | |
Re: Firstly, your trying to concatenate onto a string that's immutable [code] str1="hello";/*creates a immutable c string*/ strcat(str1,s);/*Can't do this for two reasons, one - str1 isn't big enough and two str1 in immutable*/ [/code] | |
Re: Its a good idea to initialize local variables but if the variables going to be assigned to right away then you can leave them uninitialized...Myself, I always initialize local variables. I like knowing that my program is in a valid state. One case that's essential is pointers. A pointer should … | |
Re: That's because the system stores the number as 1... 0001 and 1 are equivalent so if you need leading zeros, try storing the value as a string. | |
Re: You could try googling non-blocking I/O. | |
Re: You need to add an extra for loop like below. [code] #include <iostream> using namespace std; int main() { for (int i = 0; i < 5; ++i) { for (int j = i + 1; j > 0; --j) { cout << i + 1; } for (int j … | |
Re: For small C projects I use Gedit or Vim anything larger and I would switch to C++ and Qt Creator or KDevelop. |
The End.