Salem>Plus you seem to have generated an awful lot of code without any real testing, so any previous memory errors have gone undetected until now.
Is there a way to test the new operator? I always...
Type: Posts; User: Zarkhalar
Salem>Plus you seem to have generated an awful lot of code without any real testing, so any previous memory errors have gone undetected until now.
Is there a way to test the new operator? I always...
I do have a grasp on how memory works :/
Some parts I don't, sure. But I do create strings, I make pointers to them if I manipulate the code a lot, and I delete them when they are done.
I do find...
Maybe it's built for and ran under windows? :P
Argh, Got so far and now memory comes back to haunt me. Theres a lot more to this, though.
A segmentation fault occurs in my script if there are more than 2 lines in the configuration file that...
Err, yeah.. Whups.. Dunno why I tried to delete temp o_0;
So basically if I am playing with a dynamically allocated string, it's best to make a pointer and play with that pointer instead... ok,...
That's great, but now I can't delete temp.
I need to go through a file and parse it out. If I go over 26 in my increases in the pointer, I can't delete it
Soo, basically...
file_buffer +=...
char* file_buffer = new char[filesize + 1];
fread (file_buffer, filesize, 1, handle);
file_buffer[filesize] = '\0';
file_buffer = strchr(file_buffer, '\n') + 1;
file_buffer =...
Again, here is the real code, fully commented
fseek(handle, 0, SEEK_END); // Goes to the end possition in the file.
int filesize = ftell(handle); // gets the length of the file.
rewind...
All those things you just mentioned were mostly tests, except for the last codebox you put, which is an if statement in case something messes up in the program it gets rid of the memory first just in...
char* file_buffer = new char[filesize + 1];
fread (file_buffer, filesize, 1, handle);
file_buffer[filesize + 1] = '\0';
file_buffer = strchr(file_buffer, '\n') + 1;...
#include <stdio.h>
int main () {
FILE* fp;
if ((fp = fopen("filename", "r")) != NULL) {
// File exists if this far is reached
fclose(fp);
}
return 0;
}
I did try that.. It didn't fix the issue...
I am only using pointers to new char[]'s for this program, could that be an issue? Using only dynamic memory for strings?
A segmentation fault occurs...
I wish I knew why, but I don't. -_-
That's what I'm asking... x_X
(It's a runtime issue, program compiles fine...)
fseek(handle, 0, SEEK_END);
int filesize = ftell(handle);
rewind (handle);
char* file_buffer = new char[filesize + 1];
fread (file_buffer, filesize, 1, handle);
file_buffer =...
I ment all the strings, even though there wasn't the space for it, still printed out and all... with new, not talking about malloc
I don't even know what std::string is :P I haven't played with...
Ahh, I thought that it didn't need that =)
Thank yas
One question.. why would all the other ones work ok until this point?
Edit: Also, what if I want to change the size of it? Delete it first...
I don't even know what a vectore class is :P
If its a windows thing, I don't do it :P
char* file_location = new char;
strncat (file_location, filename, strlen(filename) - strlen(basename(filename)));
strcat (file_location, "../conf/sync.conf");
file = new char;
...
I never use cout, or any of the iostream files. Are they easier? o_0;
Salem used sscanf in a snippet of code he gave me a bit ago, and it was interesting (I've always just done strstr parsing), but I need a bit more information about sscanf and I can't find it...
Basically the topic :/
Is it possible to set an array in a function?
I'm trying to get it so I can have an array in a class without a set size, and then when I'm ready to set it's size I can do so...
Yep, I know. But when I do a strlen() on any other malloc'd variable it shows 0, while this one shows 8 o_0;
Thanks salem. Though every other malloc I use I don't add the +1 to the end, and I have no issues. This one also works fine when I remove the fclose() above it.
Thantos: I get "8" returned when I...
Why would it do that?
Here's basically what it is...
char* file_source;
file_source = (char*) malloc (strlen("Whatever I want"));
No matter what I do, setting a static int in malloc,...
That's what I'll be doing for this program, but lets say some other program I make I want to be able to install in different directories. How do I know where to get the configuration file?
For...