8,023
edits
Paradox-01 (talk | contribs) mNo edit summary |
Paradox-01 (talk | contribs) 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); | |||
} | |||
} |
edits