You are not logged in. Please login at to post your questions!


Reading character and converting to integer

In many solutions I see people reading in character in place of integer and then converting the character to integer. What effect does it have on time and memory. What is the main idea behind doing this? Can someone explain this with a good example. Thank You!

asked 02 Aug '13, 02:10

devil_coder's gravatar image

accept rate: 0%

basically it is done to reduce the time of execution...see these two codes for the problem INTEST!!!

CODE1 using scanf, time:- 5.54 secs.

CODE2 using char by char input and output, time:- 0.82 secs

for understanding this method u can refer to this post....LINK..on this link getc() is used...a faster method is to use getchar_unlocked() in place of getc()....hope this helps..:)


answered 02 Aug '13, 08:26

kunal361's gravatar image

accept rate: 21%

edited 02 Aug '13, 08:44

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Aug '13, 02:10

question was seen: 806 times

last updated: 02 Aug '13, 08:44