Friday 27 September 2013

Reversing string in c using pointers

#include <stdio.h>
#include <string.h>

void print_reverse_string(const char *str)
{
    const char *src = str + strlen(str);
    while (src > str)
        putchar(*--src);
}

void reverse_string_and_print(char *str)
{
    char *src = str;
    char *end = src + strlen(src) - 1;
    while (end > src)
    {
        char t = *end;
        *end-- = *src;
        *src++ = t;
    }
    //return str;
   printf("%s", str);
}

char* reverse_string(char *str)
{
    char *src = str;
    char *end = src + strlen(src) - 1;
    while (end > src)
    {
        char t = *end;
        *end-- = *src;
        *src++ = t;
    }

   return str;
   //printf("%s", str);
}

int  main(void){

    char data[50]= "";

    printf("Enter any string:\n");

    gets(data);

    printf("%s\n", data);
    printf("%s \n", reverse_string(data));
    printf("%s\n", data);

    return(0);
}

I have written the abbove code to reverse an string using pointers. I assume that the above code is self explanatory but still if you want any clarification use the comment section below post.

Peace.

Tuesday 3 September 2013

Finding a job in Bangalore: First Challenge

Hi

I know that there are lakhs of Berozgaar Engineers like me all over India. I  also know that most of us (Berozgaar Engineers ) have either already made a pilgrimage to Mecca of IT industry in India, Bangalore, or planning to do it pretty soon. If you are like me I have got some really valuable info for you. I am not at all kanjoos I am gonna share what ever I have learned in my past couple of months of stay in Bangalore.

Now to begin with, the reason which brought me to Bangalore was that I got a whooping 95 percentile in eLitmus test and withing a week got an interview call from Webyog. You can read about eLitmus pH test and webyog interview in my previous posts. So packed up and decide to leave for IT Mecca immediately.

The first challenge.

Getting a railway ticket to or from Bangalore is never easy, specially if you have to travel in shirt notice. And finding one is almost impossible when you have to travel the next day. Now first advice while you read the first challenge.  If you are still planning to come to Bangalore get your ticket in advance, at least one month before you are actually traveling. Continuing with my story. There were no tickets available not even waiting list. Now tatkal was the only option left.

I tried consulting with who ever I could, got some very useful information. As you might know as per the current rules Tatkal Tickets are only available one day in advance and that too after 10:00. But the interesting part is that the queue starts from 5 in the morning. Since I had to get my ticket anyhow I woke up at 4 and sped off on my ambition with lots of ambition to reservation counter almost in the middle of the night. For some of us Btechs the exact time we go to sleep. Reached there at around five and no I was not the first person in the queue, there were around 18 people before me already. Now we had to wait until ten when the counters open.

Just before ten, after some dhakka mukki and gaali galaoj queue was formed and reservation forms distributed. Exactly at ten the counters opened and number of available tickets began to drop like leave in autumn. There were total around 200 tickets. At 10:01 around 130 left, at 10:05 70 left. My heart pounding, if a doctor had taken my pulse at that time he would have definitely started my diagnosis for exterem blood pressure. I reached the counter at 10:10 and guess what? there were still 30 berths vacant, finally I got my reservation confirmed and happily returned home.

Now it was time to do packing.

Second advice: Don't count on tatkal reservation any more. Some one has written some bots for making reservation through IRCTC and a lot of agents are using it so now within a minute all tickets get sold out. And if you get to lay your hands on that bot please do share it with me too.

I think that's all I can write right now.  More to come very soon.

Peace

And there are links right at the bottom of this post to share this and all other post on all social networks , have a look. Please share it.

Bye..