XCode C++ missing sperm()

前端 未结 3 2123
谎友^
谎友^ 2021-02-20 07:56

I\'m using C++ and XCode to create a cmd line app to save file permissions, however I can\'t get the sperm() method to be identified, the error is

\'Use

3条回答
  •  花落未央
    2021-02-20 08:15

    Assuming the function is defined (and I'm not going to google that name from work), you have a problem with the way you're printing it:

    cout << "%10.10s", sperm(statbuf.st_mode);
    

    That's not going to print a formatted string, since C++ iostreams don't work like C's printf. You could either not format it:

    cout << sperm(statbuf.st_mode);
    

    or use printf:

    printf("%10.10s", sperm(statbuf.st_mode));
    

    or do some jiggery-pokery with iostream manipulators.

提交回复
热议问题