Hello.
I'am new at this language.
So i was trying to find over the internet how-to create something like cmds what linux haves. Like " mc /home/someone ", and mc will open that directory. I need to do almost the same, only i want to open image with Gtk.
My finished program should be executed like this "gimg /home/someone/pic.gif"
Hi
My question is also on a similar note. Though in my program i want to mount the usb drive and then write some files into the usb drive. How is it possible to give the prompt commands inside the program? Any help would be appreciated.
Thanks
Phro
Hello, Just a little correction for other people that may use this as a reference.
In your example argv[0] is the name of the calling program not the command line argument. the argv[1] argv[2] etc is the arguments.
1 2 3 4 5 6 7 8 9
#include <iostream>
using std::cout;
using std::endl;
int main(int args, char** argv)
{
cout << "Hi this is " << argv[0] << endl;
return 0;
}
Hey magicalblender
I dint mean program input (cout/cin), I mean to ask about commands like mkdir or cd .. can they be done inside a C program. Because at the moment i am owkring with linux. And i need to mount a usb drive before i can write information in it. What i want to do through my program is to Mount a usb drive write some files into it and unmount the usb drive. That command do unmount or mount can only be given through the cmd prompt ( mount /dev... /mnt/flash). So is there anyway to do so through the C program instead of going to cmd prompt and entering these commands.
Thanx for ur reply
Phro
I also feel the need to make sure that the user input is gathered correctly. Typically, the user expects the input to be terminated by pressing ENTER, not by any old whitespace.
1 2 3
std::cout << "Please enter some input: ";
std::string userInput;
std::getline( std::cin, userInput ); //userInput now contains ALL the text that the user typed