1,494 Posted Topics
Re: Because both strings, in foo and bar, are string literals they 'may' be stored in the text section(or some read only section) and therefore may be permanent to the process. | |
Re: This line has an extra ) int count,rec_temp[]); | |
Re: Just wait and I'll pull out the crystal ball...Yes please post the code. | |
Re: Wow..You really should download a tutorial on mysql. You haven't established a valid connection to your database, yet your preforming a query on it...Here's a brief example [code] #include <mysql/mysql.h> #include <stdio.h> int main(int argc, char **argv) { MYSQL *conn;/*connection*/ MYSQL_RES *res;/*result*/ MYSQL_ROW row;/*row*/ char server[] = "localhost"; char user[] … | |
Re: If you look at the prototype of sprintf int sprintf(char *str, const char *format, ...); You'll note that the first argument is a char *str...your passing a character on line 78 sprintf(temp_out[i], "%d", cene[i]); temp_out[i] is a character. You might be able to get away with something like below where … | |
Re: Your representation of your 2-dim array leaves a lot open for interpretation...Do you mean if you have a 2-dim array like below {a, b, c, d}{a, f, h, k} would have a final result {@, b, c, d}{@, f, h, k} | |
Re: Could be you freed a pointer *and did not set it to NULL* and then tried to free it again..The message indicates the problem lies at address 0x089b8008 *** glibc detected *** ./tryp: double free or corruption (top): 0x089b8008 *** | |
Re: I quickly looked at your 'addMyString' function...Your adding the character before you check the capacity. Shouldn't it be the other way around? | |
Re: [QUOTE=azka;1047286]Hello, i have problem at address: 0x0040E0D6 mov eax,dword ptr [ecx] the solution would be to place an instruction to check if ecx is 0 and finishing this function, but how to do this? Thx![/QUOTE] I would investigate the compare opcode and jump equal, jump not equal opcodes Try this … | |
Re: Nope, no drawbacks. The this pointer is just a pointer to the data members of the object..If omitted in member functions its assumed. Should you use it? It really depends on your preference. | |
![]() | Re: @Adak Why are you recommending [code] #define LONG 8 #define INT 4 #define SHORT 2 [/code] instead of the compile time sizeof operator? |
Re: Shouldn't this 3 5 3.9 4.5 2.1 1.0 2.4 4.3 3.1 4.2 5.1 6.2 1.0 2.7 1.2 2.3 3.1 4.2 5.2 6.4 be 3 6 3.9 4.5 2.1 1.0 2.4 4.3 3.1 4.2 5.1 6.2 1.0 2.7 1.2 2.3 3.1 4.2 5.2 6.4 | |
Re: segmentation fault results from trying to read/write from/to an invalid address.. Here's what happens when fgets() encounters the end of file or an error...Quote from my man files "char *fgets(char *s, int size, FILE *stream); gets() and fgets() return s on success, and NULL on error or when end of … | |
Re: Its been some time since I looked at pipes so I would go over this code with a fine tooth comb...You'll probably find places in the code that need improvement. [code] #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> enum PIPES {READ, WRITE}; int main(int argc, char**argv) { char ch[] … | |
Re: You could try these two functions size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); | |
Re: Where's the code that copies the data? | |
Re: Just set the pointer to NULL. void *vptr = (void*)NULL; You should get into a habit of initializing all pointers to NULL and all freed pointers to NULL. | |
Re: This requires a c string gets(me.age);//error not a short. Here's gets prototype char *gets(char *s); Also gets is a dangerous function that should never be used..Here's a short blurb on why. Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() … | |
Re: Go to this link and read [url]http://library.gnome.org/devel/gtk-tutorial/stable/[/url] | |
Re: Try initializing these values [code] int sum = 0; int average = 0; int num = 0; int i = 0; [/code] also [code] scanf( "%d", &a[SIZE]); [/code] | |
Re: You have i < (i + p)...unless p is negative(or becomes negative) you'll never exit you for loop. | |
Re: apple and orange should be enclosed in double quotes.. "orange" "apple" | |
Re: Jeez, are you posting every question in your assignment? | |
Re: Wow your instructor couldn't find the error..Try this function [code] long int power(int n,int p) { long int ans = n; int i = 1; for (; i < p; ++i) ans *= n; return ans; } [/code] | |
Re: Your if - line 58 [code] if (ans3 == 'e') cout << endl; [/code] probably should be [code] if (ans3 == 'e') { cout << endl; [/code] | |
Re: Won't this for read twice for each iteration [code] for(count = 0; count < SIZE && inputFile >> score[count]; count++); inputFile >> score[count]; [/code] Actually on second look what are you doing here? You have a for loop that reads from your file and then you have a read right … | |
Re: I would investigate the string library's function strcat() and functions like sprintf(); | |
![]() | Re: You strcat version and "Stuff" into about...What's 'about'? Can we see its definition? ![]() |
Re: You have to create your array on the heap in this situation...Returning an address to an array on the stack won't work because the address is invalid as soon as the function returns.. | |
Re: Try [code] SocketSpace::TCPSocket* SocketSpace::ServerSocket::accept() [/code] | |
Re: because your added extern extern int stack_counter; extern snode sroot; This informs the linker that both of these are defined elsewhere. | |
Re: You have major problems in your code...I tried compiling it and set off many errors and warnings...Try starting with this shell. [code] #include <iostream> #include <cstring> class string { public: string():s(NULL), itssize(0) {} string(const char* const cstring); void displayit() const { std::cout << s << std::endl; } private: char *s; … | |
Re: I tried compiling this but it has errors. You actually got this to compile? | |
Re: Line 68, your setting myfile to NULL. It should be myfile == NULL I'm surprised your compiler didn't complain about that line. I corrected it and the program works now. | |
| |
Re: Not sure what bit running = 0; is and why you need to take the address and then dereference it...Won't it make more sense to just assign 0 or 1 to running? | |
Re: Your not allocating any memory for the member variable name. This would work better if you define name as a std::string. | |
Re: Here's an example of creating a packed structure using attribute [code] struct mystr { char ca; unsigned int i; }__attribute__((packed)) thestr; [/code] | |
Re: I know this is probably radical but why don't you write some code, like below, and try it yourself. [code] #include <stdio.h> #include <stdlib.h> struct mystr { unsigned int a; unsigned int b; unsigned int c; }thestr[3] = {{0,},}; int main(int argc, char**argv) { int i; for (i = 0; … | |
Re: Here's an example of using select() which can solve your problem [url]http://linux.die.net/man/2/select_tut[/url] | |
Re: This is an accepted practice...Don't use any form of using namespace_name; in a header file. | |
Re: Its a warning so it may work...Try casting the offending variable int X=execvp ("compute",(char* const*)args); | |
Re: I'm pretty sure it has to be like this: QApplication qApp(&argc, &argv); Ooops, got GTK+ mixed up with QT4. | |
Re: Sounds like your code doesn't have a main function...Could you post the code and the compile line. | |
Re: Its an error because you can't dereference a void pointer..rbuf is a void pointer. *rbuf= &svar; What exactly are you trying to a accomplish here? What is the purpose of the program? | |
The End.