Jump to content

User:Paradox-01/C: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 84: Line 84:


----
----
Arrays, pointers, conversions, globals, ...
Arrays, pointers, conversions, globals, ...
----
==Files==
==Directories==
_getcwd can be used to get program path when main function arg is not an option.
#include <direct.h> // _getcwd
#include <stdlib.h> // free, perror
#include <stdio.h>  // printf
#include <string.h> // strlen
int main( void )
{
    char* buffer;
    // Get the current working directory:
    if ( (buffer = _getcwd( NULL, 0 )) == NULL )
      perror( "_getcwd error" );
    else
    {
      printf( "%s \nLength: %zu\n", buffer, strlen(buffer) );
      free(buffer);
    }
}
8,023

edits