If we didnt have a null terminator we would have no

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the string is over. If we didn’t have a null terminator we would have no way to tell if a sentence was finished since putting in blanks, or spaces, at the end of you sentence is completely acceptable. So this said keep in mind when finding the length of a string, that the string will be one longer then expected because of this null terminator. USAGE You may use a string in exactly the same fashion in which you use an array, specific elements may still be referenced, changed, or tested. However %s will be introduced to use with the printf command. %s much like its cousins %d or %f indicates to the printf command to print out a variable. You may have guessed the ‘s’ in %s stands for string, you would be correct, here is an example on how to use %s: char word={"hello world"}; printf("%s",word); would print to the screen: hello world HOMEWORK 1. Design a program to take two arrays of equal length , A1 and A2, and point wise add them i...
View Full Document

This note was uploaded on 05/06/2013 for the course COMP SCI 3312 taught by Professor Vrbik during the Winter '11 term at UWO.

Ask a homework question - tutors are online