Lec c9 - ComputerProgrammingITAC162. Todays Agenda...

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

View Full Document Right Arrow Icon
1 Computer Programming I TA C162 . Today’s Agenda Character Arrays One dimensional Arrays Strings Declaration Initialization Printing Reading Examples Character Manipulation in strings String Manipulation
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Computer Programming I TA C162 . Strings  Strings in C are represented by arrays of characters  End of the string is marked with a special character NULL.  The corresponding escape sequence character is ‘\0’.  C does not have string data type. Declaration of strings: char str[30]; char line[80];
Background image of page 2
3 Computer Programming I TA C162 . String Initialization: char str[9] = “I like C”;                         same as char str[9]={‘I’,‘ ’,’l’,‘i’,’k’,’e’,‘ ‘,’C’,’\0’}; Q. Is there any difference between following Initialization? char str[]=“BITS”; char str1[4]= “BITS”; Ans : Yes, in second declaration there is no null character . Also, sizeof(str) = 5 sizeof(str) = 4;
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Computer Programming I TA C162 . Reading a String (2-1)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Lec c9 - ComputerProgrammingITAC162. Todays Agenda...

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

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