Monday, December 1, 2008

Anyone Can Prorgram

"Programming is basic. It uses basic language, basic arithmetic and basic logic"

Rick Rashid
21st Century Computing Conference (21CCC)
7 Nov 2008 at Suntec Convention Centre, Singapore

Sunday, November 30, 2008

Parsing Input as String using sscanf

I'm parsing an input of string using sscanf. I found that the way sscanf behaves is funny.

My input of String looks as follows :-

1000Prasun K 1004BANGL0

Initially I used the following command to parse the input :-

scanf (acEmpRecord, "%d%[^0-9]25s%d%5s%d",
&iEmpId, acEmpName, &iDeptCode, acLocation, &iTelExt);

and I get -> 1 1000 Prasun K ╠╠╠╠╠╠╠╠Prasun K -858993460.

Supposedly, my the output should look like :-

1 1000 Prasun K BCMD BANGL -

To solve the above problem, I've removed 25s from the sscanf and the command look likes the below statement.

sscanf (acEmpRecord, "%d%[^0-9]%d%5s%d",
&iEmpId, acEmpName, &iDeptCode, acLocation, &iTelExt);

I managed to get the intended output.

Saturday, November 29, 2008

Was an Infocion

I was an Infocion (technically) a year ago. The government sent 100 of us to Mysore for IT fundamental and J2EE training. I m doing Java several years before the training and I like it.

This blog records all the Java problems that I've faced and the solution to it. Its for my own reference actually and I wish to share it with you out there.

Cheers!