0

I'm fairly new to C and am completely new to using the command prompt and GCC to compile and run my programs. I'm struggling to find the right words to ask this question properly so please bear with me, I am doing my best.

I need to use GCC to compile and run this C program but I'm getting an error that I do not understand. In this example program, I was told to use these lines to compile and run the code:

$ gcc -Wall -std=c99 -o anagrams anagrams.c 
$ ./anagrams  dictionary1.txt  output1.txt

So that is what I did. GCC does compile the program file, so the first line does not give me any error. But GCC does not like the second line, as shown below:

C:\Users\...\Example>gcc -Wall -std=c99 -o anagrams anagrams.c
C:\Users\...\Example>./anagrams dictionary1.txt output1.txt
'.' is not recognized as an internal or external command,
operable program or batch file.

Everywhere I look, it says to use "./filename" to run the program after compiling so I don't understand why it is not working for me. Any help or advice would be really appreciated.

Also, here is the main() of the program to show why those two .txt files are needed:

int main(int argc, char *argv[])
{
    AryElement *ary;
    int aryLen;

    if (argc != 3) {
        printf("Wrong number of arguments to program.\n");
        printf("Usage: ./anagrams infile outfile\n");
        exit(EXIT_FAILURE);
    }

    char *inFile = argv[1];
    char *outFile = argv[2];

    ary = buildAnagramArray(inFile,&aryLen);

    printAnagramArray(outFile,ary,aryLen);

    freeAnagramArray(ary,aryLen);

    return EXIT_SUCCESS;
}
7
  • 2
    Does anagrams dictionary1.txt output1.txt or anagrams.exe dictionary1.txt output1.txt work for you? Commented Mar 23, 2016 at 5:45
  • are you trying on windows box? The given commands should work just fine on a linux box (shell). Commented Mar 23, 2016 at 5:46
  • In both cases I get a "anagrams.exe has stopped working" crash pop-up. Commented Mar 23, 2016 at 5:48
  • 1
    Then drop ./ and debug your program. You are possibly using a lot of memory. Commented Mar 23, 2016 at 5:48
  • 1
    Well then you successfully ran the program but it crashed while executing the program. You now have to investigate and debug WHAT crashs your program. Commented Mar 23, 2016 at 5:49

1 Answer 1

5

'.' is not recognized as an internal or external command

This is not a GCC error. The error is issued by the shell when trying to run a command.

On Windows this

./anagrams  dictionary1.txt  output1.txt

should be

.\anagrams  dictionary1.txt  output1.txt

as on Windows the path delimiter is \ as opposedto IX'ish systems where it is /.

On both systems . denotes the current directory.


The reason for the crash you mention in your comment is not obvious from the minimal sources you show. Also this is a different question.

Sign up to request clarification or add additional context in comments.

3 Comments

"IX'ish systems" - Never heard of that. What's 'IX'?
@CoolGuy This refers to UNIX-like systems.
You might want to say POSIX then, as that is the standard nowadays that UNIX systems adhere to (and GNU-based systems try to imitate - poorly).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.