1,494 Posted Topics
Re: The return value of fork() will explain your questions RETURN VALUE On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no child process is created, and errno is set appropriately. | |
Re: If you want simple and complex then try VIM... | |
Re: Because Perl has so many esoteric built-in variables like - @_ or $_ or $. or $` or $& or $' or $^I...it can make the code very messy(like line noise) to the uninitiated . | |
Re: I'm not sure what your trying to accomplish here...Do you want to read each character and display it on its own line? I quickly wrote this. It will output the characters like you posted [code] #include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { char ca; FILE *fd; if (!(fd … | |
Re: Its been some time since I did any SQL but won't it be a more natural fit to use UPDATE WHERE to update a record | |
Re: How are your integers stored? Big or small endian? Also, are your integers 2 or 4 bytes? | |
Re: Number one. If your passing a pointer to an array then your function should accept a pointer to an array. int listrented(cars_t * cars2) { printf("Testing...\n"); /*shoud return something here*/ } Number two. When you call a function, you don't declare the varibles > if(choice == 3) listrented(cars_t cars[]); /*should … | |
Re: A pointer is just a variable, so coping a pointer into a pointer is done just like you showed. char *name1; char *name2; name2 = name1; Now both name2 and name1 point to the same memory area. | |
Re: It doesn't matter, its just uninitialized memory. Why do you think its a memory pointer? It could just as easily be a signed/unsigned interger...Memory is not self defining, its whatever we(the program) say it is. | |
I have a question about istream iterators and reading the input to the EOL. How do you do it? I tried the following but had to revert to a hack to get it to work. My first attempt reads from the istream but a word at a time. first.cpp #include … | |
Re: Triy this link on va_arg http://www.cplusplus.com/reference/clibrary/cstdarg/va_arg/ | |
Re: On line 27 you have a semi-colon else if (s[n] == 12); { I think that's your problem | |
Re: I think you should use a for statement to loop through your myArr array, comparing each element to the calculated average. | |
Re: Maybe, in advance, you could give us a brief description of what the code is supposed to do. | |
Please delete this...I'm new to the new Daniweb format. | |
Re: If I understand this you have the hard part all figured out. Just prompt for the numbers in your for loop and add them up and the divide by the total | |
Re: Well the first thing you'll have to do is determine page size on your computer. Then you could try something like below. [code] #include <stdio.h> #include <stdlib.h> #define MY_PAGE_SIZE 4096 int main(int argc, char** argv) { unsigned long addr = (unsigned long)&main & ((0UL - 1UL) ^ (MY_PAGE_SIZE - 1)); … | |
Re: The error message tells it all. The case needs to be a constant...Like 1,2,3,4,5...or [code] #define one 1 const unsigned long two 2; switch(angle) { case:1 {} case:two {} } [/code] | |
Re: Well 9 divides into 1 zero times with 1 left over. | |
Re: Wow I won't be forking a process that's already sporting an extra thread(the event loop). | |
![]() | Re: Just use [code] struct mys {}; struct mys * pointer = (struct mys*)malloc(num_elements * sizeof(struct mys)); [/code] |
Re: Because goto can have devastating results on your program and program flow its frowned on. If you really need to jump all over your program try a safe function like longjmp(). [code] void longjmp (jmp_buf env, int val); int setjmp ( jmp_buf env ); [/code] | |
Re: It really depends on your extraction criteria but I would start investigating functions like strtok(). | |
Re: Isn't Cygwin a Windows compiler and termios.h a Linux/Unix header? | |
Re: Have you tried using a library like [url]http://gmplib.org/[/url] | |
Re: Your kidding right? Demanding free help. | |
Re: It doesn't make sense to pass memory pointers between address spaces. | |
Re: Try defining your function like so: [code] void initFoo(foo **tmp) { ... *tmp = malloc(sizeof(foo) * 5); ... } [/code] and pass the pointer like so [code] foo *bar = NULL; /* want to create an array of 5 */ initFoo(&bar); [/code] ![]() | |
Re: Sure we'll help. What's your question or problem? Well besides its not working. | |
Re: Wow what compiler are you using - #include <iostream.h> | |
Re: [QUOTE=Jimmeny;1771865]borland c++ is fastest[/QUOTE] Why do people keep reviving these old threads? | |
Re: You could use the static keyword but I would create the array on the heap. [code] int* Bar(){ int * array = new int[2]; array[0] = 1; array[1] = 2; return array; } [/code] Just remember that you have to track and maybe delete [] this array. | |
Re: Yeah, I need a million cdn dollars maybe we can work out a deal. | |
Re: I tried this and my compiler didn't complain. [code] #include <iostream> #include <vector> #include <string> using namespace std; class GameUnit { public: string GetName() {return Name;} protected: string Name; }; class Player { public: void ListUnits(); protected: vector<GameUnit*> MyUnits; }; void Player::ListUnits() { for(unsigned int i=0; i<MyUnits.size(); i++) { cout<<MyUnits[i]->GetName()<<"\n"; … | |
Re: [QUOTE=resat.1907;1769791]Integer size is generally 4 bytes however char is only 1 byte your error is caused by thisissue in my opinion[/QUOTE] You realize this thread is 8 years old. | |
Re: Are you opening this port as a privileged user? | |
Is it possible to pass a map container to the copy algorithm and display it to the std::cout? If so how? What I tried below doesn't work but it looks like it should. Any comments or pointers will be appreciated. [code] #include <iostream> #include <string> #include <map> #include <algorithm> #include … | |
Re: You might want to put 'system("pause")' before return 0. | |
Re: Yes, I'm surprised your compiler allowed it. The assignment operator must return a reference to the object. | |
Re: try [code] #include <cstdio> int ca; ca = fgetc(stdin); [/code] | |
| |
Re: [QUOTE=rithish;1767955][CODE]#include<stdio.h> struct rec { int i; float PI; char A; }; int main() { struct rec *ptr_one; ptr_one =(struct rec *) malloc (sizeof(struct rec)); ptr_one->i = 10; ptr_one->PI = 3.14; ptr_one->A = 'a'; printf("First value: %d\n", ptr_one->i); printf("Second value: %f\n", ptr_one->PI); printf("Third value: %c\n", ptr_one->A); free(ptr_one); return 0; } [/CODE] … | |
Re: Sounds like your using unsigned characters for one and signed characters for the other. | |
Re: Maybe you could elaborate on 'this code doesn't execute'. | |
Re: Look up arbitrary precision arithmetic libraries like [url]http://gmplib.org/[/url] ![]() | |
Re: start_routine is the entrance point of the thread create with pthread_create. | |
Re: All through this program...What's the value of r? ![]() | |
Re: [quote] When I try to this, it will only print the first character of the particle name... [/quote] That's because your scanning a character [code] sscanf(line.c_str(), "%c %c %f %f %f %f %f", &(current_step.m_plus), &(current_step.m_particle), &(current_step.m_energy_sec), &(current_step.m_xpos_sec), &(current_step.m_ypos_sec), &(current_step.m_zpos_sec)); [/code] In you format string the second specifier is %c which … |
The End.