2 Replies - 1133 Views - Last Post: 01 July 2012 - 04:56 PM Rate Topic: -----

#1 Switters  Icon User is offline

  • D.I.C Head

Reputation: 25
  • View blog
  • Posts: 110
  • Joined: 03-June 12

Error: CodeBlocks / Command Line Arguments (C++)

Posted 01 July 2012 - 04:33 PM

I am working on using command line arguments--this is my first venture into the topic. I've looked through this tutorial (command line arguments) and did some searches but could not find a similar topic addressing my question. Using CodeBlocks v10.05 and WindowsXP 64-bit OS.

Right now the code is very simple (just standard "Hello World!" so not even worth posting). I think part of my challenge is that there are multiple instances of "main" in the various CodeBlocks project folders and I don't completely understand the dependencies between them (e.g., bin vs. obj folders within the overall project folder generated by CodeBlocks).

Now when I go to run my program from the command line, here is what I enter:

C:\Documents and Settings\user\Desktop\TestingCL\main

The error I get is:

Windows cannot find 'C:\Documents'. Make sure you typed the name correctly, then try again. To search for a file...etc.

Is the space in the folder "Documents and Settings" throwing this off? Everything works properly when I click "Build and Run" with Code::Blocks, so I know it is an issue related to how I am trying to use the command line.

Is This A Good Question/Topic? 0
  • +

Replies To: Error: CodeBlocks / Command Line Arguments (C++)

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 841
  • View blog
  • Posts: 2,472
  • Joined: 20-March 10

Re: Error: CodeBlocks / Command Line Arguments (C++)

Posted 01 July 2012 - 04:52 PM

Well,

Which directory are you currently in ?


You need to navigate to where your .exe (executable file) is...

If it is indeed in


C:\Documents and Settings\user\Desktop\TestingCL

Then you need to change directory don't you ?


cd C:\Documents and Settings\user\Desktop\TestingCL

Then if your .exe is called main which would be unusual then
you would then type main.exe to run it ...

If that is what you are asking ?

Snoopy.

This post has been edited by snoopy11: 01 July 2012 - 04:53 PM

Was This Post Helpful? 0
  • +
  • -

#3 Switters  Icon User is offline

  • D.I.C Head

Reputation: 25
  • View blog
  • Posts: 110
  • Joined: 03-June 12

Re: Error: CodeBlocks / Command Line Arguments (C++)

Posted 01 July 2012 - 04:56 PM

View Postsnoopy11, on 01 July 2012 - 04:52 PM, said:

Well,

Which directory are you currently in ?


You need to navigate to where your .exe (executable file) is...

If it is indeed in


C:\Documents and Settings\user\Desktop\TestingCL

Then you need to change directory don't you ?


cd C:\Documents and Settings\user\Desktop\TestingCL

Then if your .exe is called main which would be unusual then
you would then type main.exe to run it ...

If that is what you are asking ?

Snoopy.


Thanks...I think I have figured it out. I was going off of some class notes which were not very helpful. Apparently by enclosing everything up to and including main.exe
in double quotes, and then listing my command line arguments outside of the quotes, it works.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1