Question: Here is the starting code: #include #include int main(){ // array size 9 char new_string[10] = Chocolate; //array size 10 char new_string1[11] = Chocolates; //array

 Here is the starting code: #include #include int main(){ // array

Here is the starting code:

#include

#include

int main(){

// array size 9

char new_string[10] = "Chocolate";

//array size 10

char new_string1[11] = "Chocolates";

//array size 8

char new_string2[9] = "absolute";

//array size 6

char new_string3[7] = "accent";

printf("String1 contains %s ", new_string);

printf("String2 contains %s ", new_string1);

printf("String3 contains %s ", new_string2);

printf("String4 contains %s ", new_string3);

return 0;

}

Since strings are arrays, all rules about arrays apply to strings, including rules about pointers. Let's write some code that will do the same thing as printf() using a while loop and pointers. 1. Declare a pointer variable called sp. Initialize sp to the beginning of stringi. 2. Use the following pseudo code to write the while loop while sp is not the same as the null terminator print out what is at sp using printf() increment sp

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!