2 files under 1

This is a discussion on 2 files under 1 within the C Programming forums, part of the General Programming Boards category; I once saw a program that combines two programs under one name, so you could run them both at the ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    12

    2 files under 1

    I once saw a program that combines two programs under one name, so you could run them both at the same time. I tried making a program that did the same by having the program do a binary append, but the programmed that got appended didn't run. If someone could tell me how to append two files and have them both run, I would be very grateful. Thanks.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    ... 45
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    Originally posted by Salem

    I'm guessing that you want this for DOS, and the answer is ....
    **heart attack**
    The keyboard is the standard device used to cause computer errors!

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Magos
    ... 45
    You're off by 3. The answer to everything is 42.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Isn't that something like a joiner utility? To launch trojans?
    Oh of course killjoyntk won't do that

    Anyway i dunno how to do it as well

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    12
    yes it is just like a joiner program. This is the code I wrote that doesn't work like i wanted it to do
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    12
    Sorry i should have pasted my code so you didn't have to download. here is it in plain view for those who don't want to download.
    Code:
    #include<stdio.h>
    #include<stdlib.h>
    
    #define AFILE argv[1]
    #define BFILE argv[2]
    
    void bappend(FILE *from, FILE *to);
    
    
    int main(int argc, char *argv[]) {
    
    if(argc != 3) {
       printf("\nUsage: bappend <file1> <file2>");
       exit(1);
    }
    
    bappend(AFILE, BFILE);
    
    return 0;
    }
    
    void bappend(FILE *from, FILE *to) {
    
    FILE *a, *b;
    int ch;
    
    if((a = fopen(from, "rb")) == NULL) {
    	printf("\nCannot open file.");
       exit(1);
    }
    
    if((b = fopen(to, "ab")) == NULL) {
    	printf("\nCannot open file.");
       exit(1);
    }
    
    
    for(;;) {
       ch = fgetc(a);
       if(ch == EOF) break;
       fputc(ch, b);
    }
    
    fclose(a);
    fclose(b);
    }

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    12
    lol i looked at the code i pasted and there is a smiley in it. hmmm guess you would have to download it

  9. #9
    Registered User
    Join Date
    Apr 2003
    Posts
    12
    oops

  10. #10
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Just appending it like that would not work... The logic would be to write a program which will store the files.. and when launches extracts the files and uns them seperately... But if you are trying to do that for DOS forget it...

  11. #11
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I don't know enough to implement this, but it seems that you could create a menu offering the option of which program to run, stick that in the top of the .exe, and stick the two programs after that with jump instructions to them in ASM, but God, that sounds like a programming nightmare. Perhaps you could just program a menu that launched the other .exes from where they are now.
    Away.

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    21
    hey, this is basically the same as what blackrat364 suggested, but if you don't know ASM, then you could try this:

    append the program onto a little menu system prog then store where the first program and the second program start and end, then when you want to run a particular program extract the program to a temporary destinaton then once you exit the program give control back to the menu system which will then delete the program you just loaded.

    LOL, it does sound like a programming nightmare, have a play your come up with something.

  13. #13
    Registered User
    Join Date
    Apr 2003
    Posts
    12
    Hmmm. I think I better hold off on trying to make this program then becuase it sounds like it is far beyond my c skills. I am a noob at it still. Thanks for all the input everyone.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 07:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 04:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 05:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21