Question: A string is not an object in C like it is in Java - there are no objects in C. Instead, a string is an

 A string is not an object in C like it is

A string is not an object in C like it is in Java - there are no objects in C. Instead, a string is an array of characters. This can be both intuitive (what's a word? A bunch of letters) and very confusing since there is nothing that connects the functions that help with strings to the string "type". We use pointers to the beginning of the array for manipulating strings. In C, a string is not defined by its length. Instead, we put a 0 value at the end of the string. Every time we do something with the string, we look for the O value (this is called a sentinel or flag value) as the clue to stop. Another thing that some people find confusing about strings in C is that the char type can be considered as a number as well as a character. Literally, the only difference is in interpretation: 65; printf ("As a character: %, as a number: %d", a, a); char I will print As a character: A, as a number: 65 Your assignment: Using scanf(), read a string from the user. Calculate the length of the string (without using standard functions). Print your calculated length of the string, followed by the length produced by the standard functions. Submit your .c file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!