I need help - C/C++ savvy folks needed...

Discussion in 'Video Games and Technology' started by Razorclaw, Jun 9, 2010.

  1. Razorclaw

    Razorclaw Are ya gonna draw pistols

    Joined:
    Jun 7, 2003
    Posts:
    5,024
    Trophy Points:
    211
    Likes:
    +0
    I'm doing some Linux file manipulation and I ran on this bit of code:


    char* ptr=strstr(path, ".txt");
    if (ptr+4==path+strlen(path))
    {
    .........
    }


    I know the first line is creating a pointer that points to a place in the "path" string where ".txt" string starts (points to the first occurence of string ".txt"), but what does the second line do?

    Does it check if the "ends" match? "Path" string contains a file path.
     
  2. Zathras

    Zathras Vive le Quebec Libre

    Joined:
    Nov 8, 2002
    Posts:
    1,762
    Trophy Points:
    177
    Likes:
    +4
    Goes like this

    If Pointer + 4 = path + String Length of the path then execute commands in brackets

    there should be an else after that
     
  3. Razorclaw

    Razorclaw Are ya gonna draw pistols

    Joined:
    Jun 7, 2003
    Posts:
    5,024
    Trophy Points:
    211
    Likes:
    +0
    Ugh, I was asking about the condition. What does it check and if it is posible to say - why?

    In any case, I figured it out. So mods please, delete this thread. K THX BY
     

Share This Page