Thread: help! program compiles but won't run

  1. #1
    Registered User
    Join Date
    Sep 2001

    help! program compiles but won't run

    I sucessfully compiled it under linux and windows it works under linux but under windows it gives an error when I run it.

    #include <stdio.h>
    int main(int argc,char* argv[]){
      FILE *fin,*fout;
      int c;
      char key[]={(int)argv[3]}; 
    if ((fin=fopen(argv[1],"r"))==NULL){
        return 0;
      return 0;

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    You can get it to compile by changing the following bits, but even so, I don't think it's doing what you're intending it to (and it's not safe anyway).

    >char key[]={(int)argv[3]};
    Change this to:
    >char key = argv[3][0];

    Change this to:

    Do some error checking to ensure the user has provided three valid arguments, before you start indexing the argv array. Thats what I mean by "safe".

    I presume the 3rd parameter is a string key used to encrypt the file? At present you are only using the first character. There's a stack of example source for xor encryption, but if you get stuck, post again.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Help on making program run more efficiently
    By peeweearies in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 02:01 AM
  3. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  4. Make a program run at startup
    By cookie in forum Tech Board
    Replies: 2
    Last Post: 06-08-2007, 08:36 PM
  5. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM