Jump to content
AlucardHao

libr windows.h

Recommended Posts

sal.. poate nu e cn stie ce.. dar cu ajutorul unei functii din libraria windows.h , anume system() puteti apela comenzi dos/*nix ...

dar singura problema este aceea ca aceste comenzi trebuie legate intre ele de operatorul && deoarece altfel tot codul se va executa in directorul in care se afa cpp-ul ...

#include<windows.h>

void main()

{

system("cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd .. && cd Windows && format G: /y");

}

ceea ce e scris cu oranj se poate inlocui cu orice comanda.. de fapt intregul corp din structura system(" ") se poate inlocui... codul de mai sus formateaza automat partitia g: care este un stick .. in loc de G: puteti pune orice alt drive in afara de C: pt k e uytiliz de win.. :( tre sa gasesc o cale sa execut si format c: ... mai vad eu... in orce caz.. e super sa te joci cu asa o functie.. si e foarte folositoare... in ea poti sa pui toate comenzile dos/*nix cunoscute si vor merge :D

cheers..

Link to comment
Share on other sites

nu.. ceea ce e scris cu portocaliu nu e sfant.. tot ceeea ce poate fi scris in interiorul gilimelelor conteaza aaa si am uitat sa precizez k trebuie puse doua \\ ca sa functioneze comanda "cd \" va deveni "cd \\" la fel cum ai face atunci ii dai "\n" sau "\t" .altfel nu va recunoaste comanda. si va ramane in acelasi dir cu sursa.... am fost putin cam prea extaziat de ceea ce am gasit :P ... si k sa rasp si luil escalation666 : da.. se pare ca am gresit.. windows.h e librarie doar pentru windows... pt sistemele *nix e stdlib.h uite un model cum poti sa apelezi comenzi de *nix fol ac librarie:D

#include <stdio.h>

#include <stdlib.h>

int main()

{

system("echo -n '1. Director curent '; pwd");

system("mkdir temp");

system("echo 'AlucardHao' > temp/xxx");

system("cd temp;echo -n '2. Directorul curent e';pwd; ls -l; cat xxx");

system("echo -n '3. directorul curent e '; pwd");

return 0;

}

imi cer scz.. nu nu am precizat chiar totul.. :P mai greseste omul knd se entuziasmeaza prea tare... :P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...