Is there a way to write a C program to convert say Dollar to Indian Rupee (or visa-versa). The conversion parameter should not be hard coded but dynamic. More preciously it should get the latest value of Rupee vs Dollar automatically(from Internet) ?
Is there a way to write a C program to convert say Dollar to
Share
Step 1 would be to get the latest conversion rate. You can use a web-service for that. There are many available. You can try this.
Request:
Response:
For sending the request you can make use of cURL.
Once you have the response, just parse it to get the rate. Once you’ve the rate you can easily write the program to convert.
EDIT:
If using cURL is something you are not comfortable with you can make use of good old
systemandwget. For this you need to construct the URL first like:http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=INR&ToCurrency=USD
then from the C program you can do:
After this the conversion rate is in the file
result.htmlas XML. Just open it and parse it.If you are using windows, you need to install wget for windows if you don’t have it. You can get it here.