Umm, it's not overwriting past the array. Look closer at the code:
int line = 0;
int parent = 0;
while(fgets(text, 255, textFile))
{
if(feof(textFile))
break;
...
Type: Posts; User: Molokai
Umm, it's not overwriting past the array. Look closer at the code:
int line = 0;
int parent = 0;
while(fgets(text, 255, textFile))
{
if(feof(textFile))
break;
...
Thank you for the hint about data already being an array, as that's all I needed, and the clarification on strncpy was useful, but line is perfectly fine the way it is. Thanks anyway.
OK, so this program is made to read text files, split the lines into types (based on content of the lines), and then, (eventually), create a binary file from selected descriptions and their child...
Ugh... *double facepalm*... Thanks, bithub.
OK, new problem with the file name creator. Here's what I've got so far (for that):
chr = strrchr(argv[0],'\\');
if(chr == NULL)
{
puts("\nError: unable to find \"\\\" in...
And to think it was a simple case of buffer overflow this whole time (or possibly buffer underflow)... I totally did not see those two words in your post the first time...
I finally figured to...
Yeah, but still none of that is helping the problem. In fact, I figured out that the problem is in fact this block of code:
strncpy(newSaveName, (char*)argv[0], chr-argv[0]+1);
chr =...
Alright, this is what I have now:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
main(int argc, char *argv[])
{
FILE* originalSave;
Well that's all I wanted to know... Was there an easier way to do that, or was I doing the best thing I could? LOL. Anyway, all of this still hasn't solved the problem of it not working on other...
Well, that's what I'm saying, I don't want the current working directory, I mistyped that. I want the app's absolute path value.
Well, no, to me full app path is not irrelevant, because it's apparently not the directory it works in. This isn't an app I would have people install, it would just be downloaded and extracted, so I...
@tabstop: Yeah, by "package" I mean put the executable together with the new directory and the file I'm testing with, move it to another computer, and test it there. And "stops responding" refers...
@tabstop: I'm not compiling or building or coding in VS. I really don't like it. Right now, for lack of a better editor/compiler, I'm using Dev-C++.
@Sebatiani:That one I don't have any...
OK, so here's my problem now. This whole bit of code works perfectly (as long as you're converting a certain type of file). However, when I package the whole thing and try to run it on any other...
Ah, yes, of course. I needed a little allocation for that. Thank you so much. It all works perfectly now.
And yes, I had those slashes straightened out a while ago. Darn escape characters,...
Yes, I am trying to build the full path. That's why I was trying to pass all those different portions of the path in the first place.
Here's my whole code as it stands now:
#include <stdio.h>...
Yeah, I got that one. The batch file is all setup now.
Now I'm getting the problem that it won't open the new file correctly... Is there some alternative to sprintf that I can use? (other than...
I'm using dev-c++ to compile (using, I think, cygwin, maybe gcc, not sure).
Turning echo back on gives me this output:
C:Documents and Settings\User>set batPath=C:\Documents and Settings\User\My...
No, that's not the problem, because otherwise I would get something like
savePath = C:\Documents
name = and
ext = Settings\User\My
Here's what the batch file does:
@echo off
:start
set...
OK, so I figured out my problem with the endian swapping portion of my program, and now I'm trying to get it to handle file naming, etc. So I'm passing various portions of the file path to the...
OK, so I dereference it. That works. It makes it compile, and so I run it (drag and drop) with a file that has hex values of 043E7A4F. But my output confuses me... I get:
Original hex: 3E24E0...
OK, so I put in the pointer reference (&), and I still get those errors... Here's what they are exactly:
main.cpp invalid operands of types `uint32_t**' and `int' to binary `operator>>'
...
OK, so I found the C programming posts by a few people about byte-order swapping, and I've got that working just fine, but I'm a little confused as to how to grab those informations from a file,...
Oh, so for if (x == y-1), that's ok, because y-1 has to be executed for the == to be evaluated. That's a good tidbit. Thanks tabstop.
Ah, OK, so I start with i = 1 and run through the argv[]. Is argv really in char format, and does that mean that it would be in something like argv[argc][] format, or is it really a string array? ...