1,494 Posted Topics
Re: Any exec function replaces the calling image with its own..So that would explain why the calling process closes... If I was doing this, I would use the fork/exec combination. | |
Re: Try this one [code] MyMatrix: MyMatrix.o MyStringMain gcc MyMatrix.o -o MyMatrix MyMatrix.o: MyMatrix.c gcc -c MyMatrix.c MyStringMain: MyString.o MyStringMain.o gcc MyString.o MyStringMain.o -o MyString -o MyStringRun MyStringMain.o: MyStringMain.c MyString.c MyString.h gcc -c MyStringMain.c MyString.o: MyString.c MyString.h gcc -c MyString.c .PHONY:clean clean: rm -f *.o test.out [/code] | |
Re: Why would you be searching for an address in a range? You already know the address right? Are you searching for a value that may be stored in a range of addresses? | |
Re: Your function call with char * maxStr = maxn(str, 5); Does it make sense to have str[i].size(); since str[i] is a c-string? | |
Re: In C++ day = 'p' is the assignment operator not the comparison operator...You want day == 'p' See line 57 | |
Re: Firstly char* test = "ABC" creates a read only c-string so you can't modify it... You want something like char test[10] = {'A','B','C','\0'}; | |
Re: See if you can find what I changed... [code] #include <stdio.h> int NumericalAnswer; int score = 0; int main() { printf("Question 1: What's 4 x 3?\n"); scanf("%d", &NumericalAnswer); if (NumericalAnswer == 12) { printf("You got it right!"); score += 1; } return 0; } [/code] | |
Re: A few things...First what doesn't work? Next you should check to see if fopen was successful. dblPoint = fopen(BINDATA, "wb"); Did fopen succeed or fail here? | |
Re: Because its syntactically illegal. Check this link... [url]http://www.neu.edu.cn/cxsj/materal/otherc/imada/subsection3_6_2.html[/url] | |
| |
Re: What is this out(client_fd, string, readcount); Ooops, found your posted code.. You could help us out with a few remarks in your code...Also I noticed many malloc's char* string = malloc(BUFLEN); But no free's. | |
Re: "I heard in class that dynamic arrays like in java aren't supported" Hmmmm, yes they are. Try a vector. | |
Re: To see what's just do some substitution... #define TBASE_DEFERRABLE_FLAG (0x1) struct tvec_base *base First we cast base to unsigned long (unsigned long)base Then we perform the bit operation & on (unsigned long)base & 0x1 Then we cast our result to (unsigned long)(unsigned long)base & 0x1 Why do it this way? … | |
Re: First question. What is t[] an array of, characters? I ask because you pass 1 as the size in your write function. Second question...You have int val; read(fd[0],&val,1); val is an integer...its size should be sizeof(int)...e.g. read(fd[0], &val, sizeof(int)); Third question...Well more of a pointer write(fd[1],t[i],1); should be write(fd[1],&t[i],sizeof(whatever t … | |
Re: I see one potential problem here. You have a forward declaration class Retriever..Which makes me wonder??? If you have a Alsation object and call your friend function which has a reference to a Retriever how do you intend to handle the fact that your data members may deficient for a … | |
Re: The easiest way is the functionality in the XDR library(eXternal Data Represention) or if your not familiar then you could pass non c-string data by passing the start address and the length...Like this. [code] unsigned int mydata = 1234; write(clientfd, &mydata, sizeof(mydata)); [/code] Please note, you cannot pass pointers and … | |
Re: The biggest thing that I see is line 30 you call calcData() but downpayment, mort_gage, loan are uninitialized.. | |
Re: I only quickly looked at your code...I couldn't find a != operator for decimal. | |
Re: If this points to a structure.. process *state_of_queue = fcfs(q); Then use state_of_queue->structure_member or (*state_of_queue).structure_member | |
Re: [QUOTE=achieve_goals;1386402]And also, it wont let me use getline(cin, input, '@@@'), if I try to enforce that condition. Thanks in advance.[/QUOTE] That's because the delimiter has to be a character....'@' is a character but '@@@' is not. Why did you post your C++ question in the C section? | |
Re: I don't know why your allocating memory because s1 is supposed have enough room to append s2 onto it.. Here's a simple example that came with my help files [code] char* strncat(char *dest, const char *src, size_t n) { size_t dest_len = strlen(dest); size_t i; for (i = 0 ; … | |
Re: [QUOTE=MarounMaroun;1385698]Thanks [b]myk45[/b] for your help. Now, about the second question.. I don't want to allocate less of bytes, but lets say I did that.. why it won't return a segmentation fault? I just want to understand what is going on if I allocate less bytes..[/QUOTE] It probably depends on you … | |
Re: This function strcpy() expects c-strings not characters strcpy(array1[n],array[i]); array1[n] and array[i] are characters. | |
Re: The main thing is cout to fprintf [url]http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/[/url] | |
Re: I tried compiling your code but you have MS specific functionality....scanf_s doesn't work with Linux... | |
Re: If you insist on doing it this way then try the string's [] operator. [code] int i = fullName.length(); cout<<"Your reversed full Name is: "; while (i>=0) { cout<<fullName[i]; i--; } [/code] Please note that the string object has iterators which would handle this problem nicely. | |
Re: If this is a custom environment then you'll probably have to create a special linking/compiling process so your exe will execute. In truth I'm not really sure what your after? The boot floppy, is it one you created or is it one you downloaded? The kernel I have the same … | |
Re: Please get out of the habit of using gets(), its a very dangerous function. A much better solution is fgets(). Also... Your while statement assumes that the fetched c-string is 80 characters long? [code] while(i!=80) [/code] shouldn't it be [code] while(i <= strlen(array)) [/code] Also this next line is incorrect … | |
Re: Because that's the size of the pointer and not the size of the c-string. Try displaying the pointer with [code] std::cout << (void*)p << std::endl; [/code] | |
Re: Line 11 and 12...should you allocate the memory for the node first before you you allocate the memory for one of its members. | |
Re: 'It gives me a "bad_alloc" error when the obj is instantiated.'...Which object? | |
Re: Could it be the new line character in the fgets() fetched c-string. | |
Re: Could you post an example of the file or post the shell script? | |
Re: If you know how to test for one blank...then test for another one? | |
Re: Two c-strings are identical if, the starting addresses are the same or if different(starting addresses) the characters that constitute the c-string are the same. | |
Re: Well once for erek and once for the copy of erek in the function call. | |
Re: [QUOTE=vedel;1380775]yeah i know this tutorial and i try it out but it did not work[/QUOTE] I wrote something like this but didn't use C++, I used asm(16 bit) plus had to write my own linker script to get it to work... Projects like this are very interesting and the end … | |
Re: Do you mean, how does a C object file that has been linked into a C++ project, retrieve/accept the GUID of an object? | |
Re: The question is...What were you expecting? Was it something like below [code] #include <iostream> #include <cstring> using namespace std; int main(int argc, char* argv[]) { unsigned char p[] = {'1', '1', '1', '1'}; unsigned char a[4]; for(int i = 0; i < 4; i++) { a[i] = ~(p[i] - '0'); … | |
Re: Try creating a small exe with the gcc compiler then use the binutil readelf -a exename It should display all the information you need.. | |
Re: I'm a little confuse...Do you want a program that will take an inputted binary number and then produce its decimal equivalent? e.g. enter a binary number->111 ans->7 Is that what you want? | |
Re: Do you mean how large of a value? If you do then check the limits.h library | |
Re: Number one, your defining your functions inside of main..Place them before main like [code] void print_matrix(int n, int m[n][n]); // Prints an nxn matrix void print_vector(int n, int v[n]); // Prints a vector of n elements void matrix_x_vector(int n, int y[n], int x[n][n], int A[n][n]); int main() {} [/code] | |
Re: [QUOTE=frogboy77;1378671]thanks will have a look.[/QUOTE] You should check out the recommended C++ book's sticky [url]http://www.daniweb.com/forums/thread70096.html[/url] I've read Accelerated C++ and The C++ Standard Library A Tutorial and Reference and both are excellent books. | |
Re: Try setting up your VLA in a function call like so [code] #include <stdio.h> void myfunc(int size) { int i = 0; int mya[size]; for (i = 0; i < size; ++i) mya[i] = i + 10; for (i = 0; i < size; ++i) fprintf(stdout, "ans->%d\n", mya[i]); } int … | |
Re: You should be able to use array[1]->age; or (*array[1]).age; | |
Re: [QUOTE=blogoot;1379027]linux and gcc[/QUOTE] As A.D. said you'll have to provide more info. These programs, are they on the same machine or distributed over a network? Will you be using pipes, shared memory, sockets or even possibility threads? | |
Re: Why does it seg fault? Because you have to send the value that the pointer points to and not the pointer. [code] int *iptr = (int*)malloc(sizeof(int)); *iptr = 1234; /*the wrong way*/ write(sock_var, iptr, sizeof(iptr)); /*the right way*/ write(sock_var, *iptr, sizeof(int)); [/code] Note - pointers are only valid in their … |
The End.