You've pretty much got it...

The explanation I was looking for you stepped around rather than stating directly (understandably).

When you put a char into an int (or int into double, char into double, etc) the compiler does a translation to 'make it fit'. That's also true when calling or returning from a function.
It's safe up to a point. If you put an int 130 into a char, you will lose some of the number. That's what you have to be careful about.

You've pretty much got it...

thanks to you guys:)

things running as they should... i havent yet checked the outputs with self calculation yet, but things look good:) atoi() doing whatit should.. i enter 65, and im getting both 'A' and 65 in the right places....
only one thing, because of atoi(), i have to enter 'A' as 65, else it wont work...

this is the char2shrt() block:

void char2shrt(void)
{
    char input[40];
    char  ip;
    short op;
    printf("enter input:\n");
    fgets(input,39,stdin);
    printf("\nyou entered: %s",input);
    ip=atoi(input);
    printf("\nYou entry after going through atoi(): %c",ip);
    op = ip;
    printf("\nthe output in type short is: %hd",op);
}

almost there i guess... :) just if you could tell me how to input 'A' and get an output for that (if thats possible, given the nature of the code) ,it would be great :)

feeling good :)
once again, thank you so much :)

That completely depends on what you are trying to do there. You are asking for 2 types of functionality:
1) enter letters and use them as is
2) enter numbers and convert them to binary

Which do you want? What if you want to enter the character '6'? You can't do it. Your code only handles the number 6.

Think about it...

ill settle with number 6.. :) will write something else some other day for characters.. :)

this thread is solved! learned a lot .. thankyou @waltP and @deceptikon :)

kinda wish @ had the same effect like that on facebook ... maybe you guys can write a code for that too :D

We don't write code anymore. We make you do it! ;-D

We don't write code anymore

being marvin makes you so lazy! :D

We make you do it! ;-D

debugging surely makes you feel crazy?! :D (sometimes atleast..)

on a serious note...

thank you :) for helping meout with my crazy codes :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.