Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi guys,
Would anyone be knowledgeable on how to put the output of a system call into a variable using c?
Thank you in advance

usually you just put the correct variable type = then call the system call, like calling a function, thats all a system call is, a function, for example
#include
#include
#include
#includemain()
{
char* current_wd;
char buf[PATH_MAX + 1];
current_wd = getcwd( buf, PATH_MAX + 1 );if( current_wd != NULL ) {
printf( "%s\n", current_wd );
}
else
printf("call getcwd() returned NULL\n");
}
this uses the system call get cwd, its basically just doin the same as if you typed pwd on the keyboard

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |