Lab11 - Tao Lin EE140 Lab 11 1.What are the differences and...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Tao Lin EE140 Lab 11 1.What are the differences and connections between a string and a charater? A string is a special type of character. In fact, a string is an array of character type elements. Character can hold only one character, but string can hold a series of characters. However, they both defined in char data type in C. //--------------------------------------------------------------------------- //Lab#11 Q#2 Tao Lin //A program that read one string from keyboard and display the string //one character a line //-------------------------------------------------------------------------- #include <stdio.h> #include <string.h> int main( void ) { char stry[101]; int index=0; printf( "Enter one string: " ); gets(stry); //get a string while (stry[index]!= '\0' ) //loop stop when find the null value { printf( "%c\n" ,stry[index]); index++; } return 0; } RESULT: Enter one string: This is lab 11 T h i s i s l a b 1 1 Press any key to continue . . .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course EE 140 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

Page1 / 4

Lab11 - Tao Lin EE140 Lab 11 1.What are the differences and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online