Using GETS in C Sample Program

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

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

`

Battle of Smartwatches Who will Reign Supreme?

Wednesday, July 2, 2014 5:48

Wednesday, July 23, 2014   Copyright ©2010 infotechgarage.com. All rights reserved. Akeanon gid ra