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

`

Best Gear 2 Gear 2 Neo Gear Fit Screen Protector

Sunday, April 6, 2014 23:48
`

HTC One (M8) Specs and Features

Wednesday, March 26, 2014 13:25
`

Google SmartWatch Specs Features vs Gear 2

Sunday, March 16, 2014 6:55

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