G
G
Gokilla2018-02-18 01:10:53
C++ / C#
Gokilla, 2018-02-18 01:10:53

Compare file string extensions?

There is such a code, it should add the strings, but in the end we have a non-icilized variable, although the input string is suitable for one of the ifs

void__ Scene2::LoadImage(const ILstring path)
{
        ILenum ext;
  ILstring str="";
  int__ l=strlen(path);
  while(--l>0&&path[l]!='.')
    str+=path[l];
  if(strstr(str,"gnp"))
  {
    ext=IL_PNG;
  }
  if(strstr(str,"gpj") || strstr(str,"gepj"))
  {
    ext=IL_JPG;
  }
  if(strstr(str,"pmb"))
  {
    ext=IL_BMP;
       }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gokilla, 2018-02-18
@Gokilla

Decided like this:

void__ Scene2::LoadImage(const ILstring path)
{
  ILenum ext;
  
  if(strstr(path,"png"))
  {
    ext=IL_PNG;
  }
  if(strstr(path,"jpg") || strstr(path,"jpeg"))
  {
    ext=IL_JPG;
  }
  if(strstr(path,"bmp"))
  {
    ext=IL_BMP;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question