Guest User

hw basename implement

a guest
Feb 8th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <libgen.h>
  4.  
  5. void appname (char** rezname)
  6. {
  7.     printf ("%s\n", *rezname);
  8.     int rez = strlen (*rezname);
  9.     while ( ( *(*rezname+rez) != '/' ) && (--rez) ){
  10.         printf ("%d \n", rez);
  11.     };
  12.     rezname = rezname+rez;
  13. }
  14.  
  15. int main (int argc, char* argv[]){
  16.     char* buf=argv[0] ;
  17.     appname (&buf);
  18.     printf ("Hello, world, it my first programm named \"%s\"\n", basename(buf));
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment