Using GETS in C Sample Program

Wednesday, August 1, 2012, 3:04 Latest News

By Jo Teach

Using GETS in C Sample Program

Using the string Data type in C, this is usually the first option in displaying text in C, by invoking the %s, & Variable in the scanf() input function to read any data in inputs.







But the problem with the string  input is that it is not able to show two words  when you try to display the data, using gets is far more powerful and able to display two or more words in an input, see the sample program below for the Gets.

#include<stdio.h>

char a[30], b[30];

main( )

{

clrscr();

printf(“Item Name1:”);

gets(a);

printf(“Item Name2:”);

gets(b);

printf(“Items bought”);

printf(“nItem1:%s”,a);

printf(“nItem2:%s”,b);

getch();

return 0;

}

Using Gets in C Sample Program

Related Topics:

    None Found

Please Like Us on Facebook to get the latest updates on info tech and world news!
Custom Search

Latest Articles

` Starmobile Astra Android Specs Price Review

Starmobile Astra Android Specs Price Review

Friday, May 17, 2013 13:20
` Lamborghini Egoista Photos Car of the Future

Lamborghini Egoista Photos Car of the Future

Monday, May 13, 2013 13:14
` Cherry Mobile SkyFire 2.0 Specs Reviews Price

Cherry Mobile SkyFire 2.0 Specs Reviews Price

Sunday, May 12, 2013 7:01

Infotechgarage.com

Accepts contributor or just guest post, so if you are interested in being a contributor or just a guest blogger/writer please feel free to read the guidelines for contributor or guest blogger/writer.

Read : Be a Contributor /Guest Post

Enter your email add







Welcome to infotechgarage.com beta, feel free to browse the site for informative articles related to information technology and other articles in the world wide web.

Saturday, May 18, 2013   Copyright ©2010 infotechgarage.com. All rights reserved. Akeanon