All that is necessary for evil to succeed is that good people do nothing! Support Act for America

how do i execute a command in C code? - Anarchist Cookbook
Anarchist Cookbook  

Go Back   Anarchist Cookbook > Anarchist Cookbook > Hacking > Programming

Programming Got code?

Reply
 
Thread Tools Search this Thread Display Modes
Old November 28th, 2008   #1
twenglish1
Senior Member
Points: 5,393, Level: 31
Points: 5,393, Level: 31 Points: 5,393, Level: 31 Points: 5,393, Level: 31
Activity: 22%
Activity: 22% Activity: 22% Activity: 22%
 
twenglish1's Avatar
 
Kill Tweety Champion!
Last Online: 2 Hours Ago 11:55 PM
Join Date: Aug 2008
Location: Pittsburgh, PA
Age: 15
Posts: 2,001
Cash Credits: 24,133
twenglish1 RSS Feed
how do i execute a command in C code?

i am new to C programming but i am learning. i am trying to make a program that will format a drive but i don't know what code i would use to execute the format command.

here is the code:

#include "stdio.h"

int main(void){
char drive;
char x;
printf("Enter Drive letter:\n");
scanf("%c", &drive);
printf("Drive %c will now be formatted!\n", drive);
(format command goes here)
return 0;
}

what do i use to format the drive please help!!!
twenglish1 is offline   Reply With Quote
Old January 12th, 2009   #2
gray_hat
Junior Member
Points: 298, Level: 5
Points: 298, Level: 5 Points: 298, Level: 5 Points: 298, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 

Last Online: May 27th, 2009 07:57 AM
Join Date: Jan 2009
Posts: 16
Cash Credits: 434
gray_hat RSS Feed
A useful function for this is system(). The argument that this function takes is the command that you want executed, whatever you insert in the parentheses will be executed as if it is in a terminal/bash. For example:

int main(void) {

system("clear");
return 0;

}

will clear the screen anytime it is ran. So maybe something like:

#include "stdio.h"

int main(void){
char drive;
char x;
printf("Enter Drive letter:\n");
scanf("%c", &drive);
printf("Drive %c will now be formatted!\n", drive);
system("<command to format drive here>");
return 0;

}
gray_hat is offline   Reply With Quote
Old January 12th, 2009   #3
Cuddles
Senior Member
Points: 8,263, Level: 39
Points: 8,263, Level: 39 Points: 8,263, Level: 39 Points: 8,263, Level: 39
Activity: 48%
Activity: 48% Activity: 48% Activity: 48%
 
Cuddles's Avatar
 

Last Online: 13 Hours Ago 01:14 PM
Join Date: Dec 2005
Location: i dont know, but its aweful hot...
Posts: 2,028
Cash Credits: 6,367
Cuddles RSS Feed
Send a message via AIM to Cuddles Send a message via MSN to Cuddles
first, dont necropost, second, dont help morons on this site with trivial shit, they usually have bad intentions, like formatting their school computers......
__________________
Caution: the above post may cause anal leakage if not taken with alcohol.
Cuddles is offline   Reply With Quote
Old January 12th, 2009   #4
ishkur88
Senior Member
Points: 5,313, Level: 31
Points: 5,313, Level: 31 Points: 5,313, Level: 31 Points: 5,313, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
ishkur88's Avatar
 

Last Online: 1 Day Ago 06:01 PM
Join Date: Nov 2006
Location: the internet.
Age: 25
Posts: 1,104
Cash Credits: 6,001
ishkur88 RSS Feed
Send a message via AIM to ishkur88 Send a message via MSN to ishkur88 Send a message via Yahoo to ishkur88
Plus, that won't work. You can't format a partition that you're using. Best you can hope to do is delete a bunch of shit and make the OS unstable.

And my God, you're using C.... why even try to make the call to system? There should be a fancier way of doing that.
__________________
I am not young enough to know everything.
ishkur88 is offline   Reply With Quote
Old January 12th, 2009   #5
twenglish1
Senior Member
Points: 5,393, Level: 31
Points: 5,393, Level: 31 Points: 5,393, Level: 31 Points: 5,393, Level: 31
Activity: 22%
Activity: 22% Activity: 22% Activity: 22%
 
twenglish1's Avatar
 
Kill Tweety Champion!
Last Online: 2 Hours Ago 11:55 PM
Join Date: Aug 2008
Location: Pittsburgh, PA
Age: 15
Posts: 2,001
Cash Credits: 24,133
twenglish1 RSS Feed
ok first of all im not trying to use it for a virus, i mean i know this is in hacking but its also under programming, i don't plan on formatting an active hard drive i know that doesn't work, i am making a program that sets up a usb drive for something, this includes formatting it and then copying the files to it. but whatever i'll try it
twenglish1 is offline   Reply With Quote
Old January 12th, 2009   #6
deathlord888
Senior Member
Points: 14,704, Level: 52
Points: 14,704, Level: 52 Points: 14,704, Level: 52 Points: 14,704, Level: 52
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
deathlord888's Avatar
 
3D Net Blazer Champion!
Park Soccer Champion!
Heidi: Throw the bell Champion!
Mind Me Bloody Beer Champion!
Tournaments Won: 1

Last Online: 2 Hours Ago 11:51 PM
Join Date: Jul 2006
Age: 18
Posts: 4,029
Cash Credits: 50,874
deathlord888 RSS Feed
Send a message via MSN to deathlord888
lol you need to start with WAY WAY easier things than that...
__________________
I HATE MY SN
Quote:
Originally Posted by AssRot View Post
Smiling is for girls and fags
deathlord888 is offline   Reply With Quote
Old January 12th, 2009   #7
Cuddles
Senior Member
Points: 8,263, Level: 39
Points: 8,263, Level: 39 Points: 8,263, Level: 39 Points: 8,263, Level: 39
Activity: 48%
Activity: 48% Activity: 48% Activity: 48%
 
Cuddles's Avatar
 

Last Online: 13 Hours Ago 01:14 PM
Join Date: Dec 2005
Location: i dont know, but its aweful hot...
Posts: 2,028
Cash Credits: 6,367
Cuddles RSS Feed
Send a message via AIM to Cuddles Send a message via MSN to Cuddles
Quote:
Originally Posted by deathlord888 View Post
lol you need to start with WAY WAY easier things than that...
...whut are you talking about?

as to the question: if you want to set up a usb drive, what do you need to format it for? are you trying to make it bootable? are you trying to move--you know what, tell me the details of what you're trying to do, and ill try to help, asking random questions that come to mind isnt really gonna be of much help
__________________
Caution: the above post may cause anal leakage if not taken with alcohol.
Cuddles is offline   Reply With Quote
Old January 12th, 2009   #8
twenglish1
Senior Member
Points: 5,393, Level: 31
Points: 5,393, Level: 31 Points: 5,393, Level: 31 Points: 5,393, Level: 31
Activity: 22%
Activity: 22% Activity: 22% Activity: 22%
 
twenglish1's Avatar
 
Kill Tweety Champion!
Last Online: 2 Hours Ago 11:55 PM
Join Date: Aug 2008
Location: Pittsburgh, PA
Age: 15
Posts: 2,001
Cash Credits: 24,133
twenglish1 RSS Feed
ok, i am trying to make a program that creates magic memory sticks for softmodding the psp, it was just out of being bored, cause i can easily make one with a command prompt, i just though it would be interesting to make a c program do it, and im still teaching myself c so i don't know everything about it
twenglish1 is offline   Reply With Quote
Old January 12th, 2009   #9
Cuddles
Senior Member
Points: 8,263, Level: 39
Points: 8,263, Level: 39 Points: 8,263, Level: 39 Points: 8,263, Level: 39
Activity: 48%
Activity: 48% Activity: 48% Activity: 48%
 
Cuddles's Avatar
 

Last Online: 13 Hours Ago 01:14 PM
Join Date: Dec 2005
Location: i dont know, but its aweful hot...
Posts: 2,028
Cash Credits: 6,367
Cuddles RSS Feed
Send a message via AIM to Cuddles Send a message via MSN to Cuddles
i thought there were programs that did that already.....as to doing it in c, if you're gonna use system, you might as well just use a batch file, it'll be doing the same job, only you wont need to compile every time you change something....and it'll be a little easier to edit....but if you really want to do it in c, just make a batch file that does it, and for every line in the batch file, make a system call in your c programme's source containing the line.....if you dont want to do that, look into formatting drives in c online, google will be a better resource than asking on a forum, in this case
__________________
Caution: the above post may cause anal leakage if not taken with alcohol.
Cuddles is offline   Reply With Quote
Old January 12th, 2009   #10
twenglish1
Senior Member
Points: 5,393, Level: 31
Points: 5,393, Level: 31 Points: 5,393, Level: 31 Points: 5,393, Level: 31
Activity: 22%
Activity: 22% Activity: 22% Activity: 22%
 
twenglish1's Avatar
 
Kill Tweety Champion!
Last Online: 2 Hours Ago 11:55 PM
Join Date: Aug 2008
Location: Pittsburgh, PA
Age: 15
Posts: 2,001
Cash Credits: 24,133
twenglish1 RSS Feed
i know i could use a batch file, thats what i did anyways, but i wanted to take it a step further and do it in c, and i searched google but didn't find much
twenglish1 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:23 AM.


Powered by Anarchy and vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios