[ create a new paste ] login | about

Link: http://codepad.org/pOV2inep    [ raw code | output | fork ]

C++, pasted on Aug 18:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

bool check_extention (const std::string& filename)
{
  const char* ext = ".cpp";
  return !strcmp(filename.c_str() + filename.length() - strlen(ext), ext);
}


int main()
{
  std::cerr << check_extention("hoge.cpp") << std::endl;
  std::cerr << check_extention("hoge.c") << std::endl;
  return 0;
}


Output:
1
2
1
0


Create a new paste based on this one


Comments: