Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

argv to octal?? 1

Status
Not open for further replies.

LanceDrolet

Programmer
Apr 11, 2005
3
US
Hi..

A project at school has me reinventing the wheel. I'm required to re-write several linux command line apps using the associated system calls. The problem I'm having is with CHMOD.

It works fine, when I embed the mode I want to change the file to in the code. The problems start when I try using the command line arg. I've tried using "chmod(argv[1], *argv[2]);" but what ends up happening is the permissions get changed to the octal representation of what's typed in for argv[2].

So it seems I need to come up with a way to change the string returned by argv[2] to an octal, or change the int returned by atoi(argv[2]) to an octal.

Any suggestions??

Thanks...
 
Try using [tt]strtol[/tt]. That function lets you specify the base used to turn a string into an int.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top