Accepting a set number of characters in Char

Hello there,

Im trying to get my program to accept only the first 2 characters of an input from a char type.
eg.

char egstring[] = "This is an example";
printf("%s", egstring); // suppose to print only "Th"

I was thinking that is it possible to insert a \0 after the first two characters to just end it, hence printing only the first 2 characters?

But im not really sure how to do this, could someone please give me a hand.

Thanks
Topic archived. No new replies allowed.