prakaashganth d wrote:
> Hi People,
> I have a doubt in C program.
> Suppose i have declared int i = 1234;
> If I want to print only 12 (first 2 digits) using printf statement, please
> suggest how do i implement it.
>
> Regards,
> prakash.
printf("%i\n", i / 100);
Although, if you are wanting a general solution, convert it first to a
string, then lop off the first two bytes and display those. Here's how
I would personally do that (requires BString from Safe C++ Design
Principles):
printf("%s\n", *BString(i).Left(2));
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/