lundi 17 juin 2019

issue with

Unable to get basename to work in C++, I am trying to just get the code to compile.

This is for a school assignment and I have tried to see if it is my stdlib having issues -- however, it seems that the problem is that

'''c++

#include<iostream>
#include<cstring>
#include<libgen.h>
int main(){
  const char *ch = "asdfasdf/asdf.cpp";
  std::cout<<basename(ch) << std::endl;
  std::cout<<dirname(strdup(ch)) << std::endl;
  return 0;
}

I was supposed to print out the output of ch, however, instead I get the error message:

test.cpp:8:14: error: no matching function for call to 'basename' std::cout<enter code here /usr/include/libgen.h:40:7: note: candidate function not viable: 1st argument ('const char *') would lose const qualifier char *basename(char *); ^ 1 error generated.

Aucun commentaire:

Enregistrer un commentaire