The line fullpath = temp; doesn't actually reset the var. I am not sure what I have to do. I have tried fullpath = *temp;. Could someone tell me why this is not working?
#include "stdio.h"
#include "stdlib.h" //Used for getenv();
#include "string.h" //Used for strcat();
int main(int argc, char* argv[])
{
//Make vars
FILE *self;
FILE *ext;
int lengthof;
int sum;
int fatpos;
int i;
int fcount;
char filename[32];
char *filedata;
char *temp;
char *fullpath;
const int F_SIZE = 6144; //Size of this program (the stub)
//Open self, set pointer to the end of the stub
self = fopen(argv[0], "rb");
fseek(self, F_SIZE, SEEK_SET);
//Read integer for number of files in archive
fread(&fcount, sizeof(int), 1, self);
//Figure out how long the FAT is
sum = ((32 + sizeof(int)) * fcount) + sizeof(int);
//Set up the position saver thing (used to keep the position in the FAT so program can seek back after file is read)
fatpos = F_SIZE + sizeof(int);
//Get the location of the temporary directory
temp = getenv("TEMP");
if(strlen(temp) > 3)
{
strcat(temp, "\\");
}
//Loop through the file names
for(i = 0; i < fcount; i++)
{
fread(filename, 32, 1, self); //Read the file name of 32 bytes max (will auto terminate at zero byte)
fatpos += 32; //Add 32 to the position
fread(&lengthof, sizeof(int), 1, self); //Get length of file
fatpos += sizeof(int); //Add a long to the position
fseek(self, F_SIZE + sum, SEEK_SET); //Go to the file
sum += lengthof; //Add to the length …