Thursday, 28 March 2013

How to use Whatsapp on PC


I have seen many yahoo questions and google queries about "HOW to use Whatsapp on a PC","Whatsapp for Computer","Whatsapp for MAC/Windows".
Now here is a trick How you all can Download and use Whatsapp for your MAC and Windows machine..!!



Step 1. Download and Install
BlueStacks for Windows or Mac OSX.

Step 2. Open BlueStacks.
Step 3. Click on the Search icon on top right corner.
Step 4. Enter WhatsApp and click on Find button.
Step 5. Click the Install button next to WhatsApp.
Step 6. Start WhatsApp Messenger on BlueStack
Step 7. You will now have to enter your phone number.
Step 8. Enter the 6 digit verification code...!! and thats it...!!

isn't is amazing..!!

apart from Whatsapp only you can also run all your andoroid apps or all mobile apps on your PC itself..!!



Bluestack app player lets you run apps from your phone fast and full screen on MAC and Windows.

Tuesday, 26 March 2013

Create a folder named as "CON" in Windows



Hello all ..!!


Today i'll show you some cool windows tricks,which you may don't know..!!

many people say that you cannot create a "CON" folder in windows...!!


I"ll show u how you can create a folder with name "con" "prn" "null" etc.


follow these steps..!


1. Open "cmd" with administrative privileges.

2. Go to the directory where you want to create the folder by using "cd" command which is used to change the directory.


for ex. if u want to create the folder in the 'D" drive of your computer then type : "cd d:" or simply "d:" and hit 'enter"


3. Then type "md\\.\d:\con" and hit enter.

4. Now go to your D: drive and check there...there is a folder named as "con" will be created.

5. Simply it you want to remove that directory just type in command prompt "rd\\.\d:\con" and hit enter.

your folder will be removed from that drive..!



similarly you can make folders named as "prn" and "null" also...!



Thursday, 14 March 2013

Threads Program using C on linux/fedora



This program creates a single extra thread, shows that it is sharing variables with the original thread, and gets the new thread to return a result to the original thread. Multithreaded programs don't get much simpler than this.
Lets look the function which create the thread. pthread_create creates a new thread,much as fork creates a new process.

#include<pthread.h> 
int pthread_create(pthread_t *thread, pthread_attr_t *attr, void(*start_routine)(void *), void *arg); 

The first argument is a pointer to pthread_t . When a thread is created, an identifier is written to the memory location to which this variable points.This identifier enables you to refer to the thread . The next argument sets the thread attributes. You do not usually need any special attributes, and you can simply pass NULL as this argument. Later is the chapter you will see how to use these attributes. The final two arguments tell the thread the function that it is to start executing and the arguments that are to be passed to this function.



1
Void *(*start_routine)(void *)
The preceding line simply says that you must pass the address of a function taking a pointer to void as a parameter and the function will return a pointer to void.
When a thread terminates, ti calls the pthread_exit function, much as a process calls exit when it terminates. This function terminates the calling thread , returning a pointer to an object. Never use it to return a pointer to a local variable, because the variable will cease to exist when the thread does so, causing a serious bug. pthread_exit is declared as follows.
1
2
3
#include<pthread.h>
void pthread_exit(void *retval);
</pthread.h>
pthread_join is the thread equivalent of wait that processes use to collect child processes. This function is declared as follows:?
1
2
3
#include <pthread.h>
int pthread_join(pthread_t th , void **thread_return);
</pthread.h>
The first parameter is the thread for which to wait, the identifier that pthread_create filled in for you. The second argument is a pointer to a pointer that itself points to the return value from the thread. Like pthread_create, this function returns xero for success and an error code on failure.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//programThread.c
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
void *thread_function(void *arg);
char message[] = "Hello World";
int main() {
    int res;
    pthread_t a_thread;
    void *thread_result;
    res = pthread_create(&amp;a_thread, NULL, thread_function, (void *)message);
    if (res != 0) {
        perror("Thread creation failed");
        exit(EXIT_FAILURE);
    }
    printf("Waiting for thread to finish...\n");
    res = pthread_join(a_thread, &amp;thread_result);
    if (res != 0) {
        perror("Thread join failed");
        exit(EXIT_FAILURE);
    }
    printf("Thread joined, it returned %s\n", (char *)thread_result);
    printf("Message is now %s\n", message);
    exit(EXIT_SUCCESS);
}
void *thread_function(void *arg) {
    printf("thread_function is running. Argument was %s\n", (char *)arg);
    sleep(3);
    strcpy(message, "Bye!");
    pthread_exit("Thank you for the CPU time");
}
</pthread.h></string.h></stdlib.h></unistd.h></stdio.h>
Now steps for compiling the source code.
If you are using codeblocks IDE in fefora then you must have to add library file libphread.so file in linker setting which you can do form setting/compiler and debugger menu. Library filelibphread.so is in usr/lib or user/lib64 directories.

If you are using the command line shell then use following command to compile.

$ cc D_REENTRANT programThread.c -o programThread -lpthread