Tuesday, September 23, 2008
C Manual Pages in Ubuntu
sudo apt-get install build-essential gcc-3.3-doc c-cpp-reference
apt-cache search gcc|grep doc
sudo apt-get install manpages-posix
sudo apt-get install manpages-posix-dev
Tuesday, September 09, 2008
Command Line Arguments, C programming
C provides a fairly simple mechanism for retrieving command line parameters entered by the user. It passes an argv parameter to the main function in th e program. argv structures appear in a fair number of the more advanced library calls, so understanding them is useful to any C programmer.
Enter the following code and compile it:
In this code, the main program accepts two parameters, argv and argc. The argv parameter is an array of pointers to string that contains the parameters entered when the program was invoked at the UNIX command line. The argc integer contains a count of the number of parameters. This particular piece of code types out the command line parameters. To try this, compile the code to an executable file named aaa and type aaa xxx yyy zzz. The code will print the command line parameters xxx, yyy and zzz, one per line.
The char *argv[] line is an array of pointers to string. In other words, each element of the array is a pointer, and each pointer points to a string (technically, to the first character of the string). Thus, argv[0] points to a string that contains the first parameter on the command line (the program's name), argv[1] points to the next parameter, and so on. The argc variable tells you how many of the pointers in the array are valid. You will find that the preceding code does nothing more than print each of the valid strings pointed to by argv.
Because argv exists, you can let your program react to command line parameters entered by the user fairly easily. For example, you might have your program detect the word help as the first parameter following the program name, and dump a help file to stdout. File names can also be passed in and used in your fopen statements.
Source : http://computer.howstuffworks.com/c38.htm
Sunday, September 07, 2008
Setting up Persian language in Ubuntu
Code:
setxkbmap -option grp:switch,grp:shift_toggle,grp_led:scroll us,ir &
If it works then you just need to have this line executed everytime you login (for example have it in a script that will be run in your profile or in your Autorun)
Source : http://ubuntuforums.org/showthread.php?t=198188
Wednesday, September 03, 2008
install C/C++ on your Ubuntu, HOWTO
Install C and C++ Compilers in Ubuntu
sudo aptitude install build-essential
This will install all the required packages for C and C++ compilers
Testing C and C++ Programs
Compiling Your first C Programs
Now you need to open first.c file
sudo gedit first.c
add the following lines save and exit the file
Firstly compile the code using the following command
cc -c first.c
that would produce an object file you may need to add to the library.
then create an executable using the following command
cc -o first first.c
Now run this executable using the following command
./first
Output should show as follows
Hello, world
Compiling your first C++ program
If you want to run c++ program follow this procedure
g++ is the compiler that you must use.
you should use a .cpp file extension rather than a .c one
You need to create a file
sudo gedit first.cpp
add the following lines save and exit the file
Run your C++ Program using the following command
g++ first.cpp -o test
./test
Output should show as follows
Hello World!
Source : http://www.ubuntugeek.com/how-to-install-c-and-c-compilers-in-ubuntu-and-testing-your-first-c-and-c-program.html
How to install VLC media player on Ubuntu
You need to check that a "universe" mirror is listed in your /etc/apt/sources.list.
% sudo apt-get update
% sudo apt-get install vlc vlc-plugin-esd mozilla-plugin-vlc
How to change the root password in Ubuntu
In Linux (and Unix in general), there is a superuser named root. The Windows equivalent of root is Administrator. The superuser can do anything and everything, and thus doing daily work as the superuser can be dangerous. You could type a command incorrectly and destroy the system. Ideally, you run as a user that has only the privileges needed for the task at hand. In some cases, this is necessarily root, but most of the time it is a regular user.
By default, the root account password is locked in Ubuntu. This means that you cannot login as root directly or use the su command to become the root user. However, since the root account physically exists it is still possible to run programs with root-level privileges. This is where sudo comes in - it allows authorized users (normally "Administrative" users; for further information please refer to AddUsersHowto) to run certain programs as root without having to know the root password.
This means that in the terminal you should use sudo for commands that require root privileges; simply prepend sudo to all the commands you would normally run as root. For more extensive usage examples, please see below. Similarly, when you run GUI programs that require root privileges (e.g. the network configuration applet), use graphical sudo and you will also be prompted for a password (more below). Just remember, when sudo asks for a password, it needs YOUR USER password, and not the root account password.BUT anyway, if you really want to make the root user, you can do as followed :
To manually set a password for the root user, type in the following in the shell:sudo passwd
After that you are asked to type in the new root password twice. Finally, your root user has its own password.
Logging in as another user
sudo -i -u username
For example to become the user amanda for tape management purposes.
sudo -i -u amandaThe password being asked for is your own, not amanda's.