Computing.Net > Forums > Linux > System call into a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

System call into a variable

Reply to Message Icon

Name: chadyazzi
Date: November 21, 2002 at 13:07:33 Pacific
OS: Linux
CPU/Ram: 32 ram
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: steve
Date: December 12, 2002 at 16:17:12 Pacific
Reply:

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
#include

main()
{
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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: System call into a variable

Error when add a new system call. www.computing.net/answers/linux/error-when-add-a-new-system-call/23180.html

loading linux into a processsor www.computing.net/answers/linux/loading-linux-into-a-processsor/29756.html

memory usage system call www.computing.net/answers/linux/memory-usage-system-call/7879.html