Explanation

Hi everybody,

someone could explain me what the following code do ?
And more particularly the functions or writing:
- getopt
- strcpy
- the arrow in: dietsession->m_cfgFile
- the (AV_t) in: dietsession->m_Av = (AV_t) atoi(optarg)

I already searched on google but I cannot find some good explanations about the writting.

Thanks for your help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
while((c=getopt(agrc,argv,"fcu:")) 1= -1)
{
 switch(c)
  {
   case'f':
    strcpy(dietsession->m_cfgFile,optarg);
    break;
   case'c':
    dietsession->numCam = atoi(optarg);
    break;
   case'u':
    dietsession->m_Av = (AV_t) atoi(optarg);
    break;
  }
}
1) http://www.gnu.org/s/hello/manual/libc/Getopt.html
2) http://www.cplusplus.com/reference/clibrary/cstring/strcpy/
3) This is a pointer derefence/dot operator combination. It has the same effect as:

(*dietsession).numCam

4) This is a cast, telling the compiler to interpret whatever is on the right side as an "AV_t" (whatever that is)
Thanks a lot.
Topic archived. No new replies allowed.