[Insight-users] Re : Re : Need to correct this example

Syrine Sahmim syrine.sahmim at yahoo.fr
Tue Aug 4 15:55:49 EDT 2009


Hi, 


>>I don't know what you mean with "debogue from c++". Do you mean
"debug"? What are you doing? Are you typing something? Are you clicking
>>with the mouse on an icon?
debogue (in french) it means debug: i just click on an icon with mouse . after building project in C++ i must debug it by clicking on icon "start debugging". that i do with any example of itk. that 's why i said i don't know where can i gives the arguments.
Thank you

Regards
Syrine


________________________________
De : Ramón Casero Cañas <ramon.casero at comlab.ox.ac.uk>
À : Syrine Sahmim <syrine.sahmim at yahoo.fr>
Cc : insight-users at itk.org
Envoyé le : Mardi, 4 Août 2009, 19h44mn 35s
Objet : Re: [Insight-users] Re : Need to correct this example

Syrine Sahmim wrote:
> Hi,
> I'm really ashamed. i know i disturb you from your work.i have buy a book of c++ and i use internet but in  vain i still don't know many things and i still learning at the same time. i will try and try to command better c++ and itk.the begining is still difficult.Really thank you for your help but want to konw others things if itis possible:

Hi Syrine,

Nothing to be ashamed of, but yes, it seems that you need to get yourself familiar with programming.

What's your background? Are you taking a course in programming, are you in college...? Do you have access to lectures or a technical library?


> you have said :
>>> Do not do that. Pass the arguments in at the command line properly.
>>> Also if argc =2 then only argv[0] and argv[1] are valid. C starts
>>> counting at 0.
> please explain more to me what i must do step by step:
> how do  i  pass the arguments at the command line properly . it's one of my problem? what i must do exactly
> all i know that i debogue from c++ and after that i'll have the ms dos screen and i haven't the posibility to write the arguments in this screen because it's mentioned that i should clik to any key in the key board.


I don't know what you mean with "debogue from c++". Do you mean "debug"? What are you doing? Are you typing something? Are you clicking with the mouse on an icon?


The command line, or command prompt in Windows [1][4], is typically a black window with silver letters. You can type commands there (you don't use the mouse). A command will usually run a program.

For example, if you have a program called "RegistrationExample.exe", then you can run it by typing

C:\> RegistrationExample.exe

Now suppose that your program needs some input arguments, for example 2 DICOM files with the data you are trying to register.

Suppose also that this program in particular expects the first input argument to be the file name of the fixed image, and the second argument to be the file name of the moving image. This is known as the "syntax". When you try to run the program without arguments, it will usually show you the expected syntax:

Syntax:

RegistrationExample.exe fixed.dcm moving.dcm


So now you want to run something like this, using the command line

C:\> RegistrationExample.exe heart1.dcm heart2.dcm


OK, so this is all from the point of view of the user and the command line. Now we are going to look at this from the point of view of the person writting the C++ program.

When you are writing a program in C++ yourself, or using one of the Examples in ITK, what you get is a source code file with extension .cpp, that contains several things.

One of these things is the "entry point", that is, the main() function [2].

A common way of working with main() is the following

<CODE>
int main( int argc, char *argv[] )
{

// your program code here
}
</CODE>

argc is a numerical variable, and it contains the _number_ of input arguments.

argv is an array of strings that contains the _input argments_.

For example, if you call your program with

C:\> RegistrationExample.exe heart1.dcm heart2.dcm

then you will have

argc --------> 3
argv[0] -----> "RegistrationExample.exe"
argv[1] -----> "heart1.dcm"
argv[2] -----> "heart2.dcm"

You can read more about this with a Google search, for example [3]


[1] http://en.wikipedia.org/wiki/Command_Prompt_(Windows)
[2] http://en.wikipedia.org/wiki/Main_function_(programming)
[3] http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html
[4] http://www.bleepingcomputer.com/tutorials/tutorial76.html

Cheers,

Ramon.

-- Ramón Casero Cañas, DPhil

Computational Biology, Computing Laboratory
University of Oxford
Wolfson Building, Parks Rd
Oxford OX1 3QD

tlf     +44 (0) 1865 610807
web    http://web.comlab.ox.ac.uk/people/Ramon.CaseroCanas
photos  http://www.flickr.com/photos/rcasero/



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090804/ebb3cf3e/attachment.htm>


More information about the Insight-users mailing list