Beruflich Dokumente
Kultur Dokumente
Assignment 1:
Put a = 2, b = 3 and then assert that a==3 and b==2 after applying the swap function in
each
case, Explain your answer.
Q4 Write a program to count the number of vowels in the following array of pointers to
strings:
char * str[ ] = {
Friends is an American television sitcom,
created by David Crane and Marta Kauffman
which originally aired on NBC
}
Q5
#include<stdio.h>
char *c[]={"ENTNG","NST","AMAZI","FIRBE"};
char **cp[]={c+3,c+2,c+1,c};
char ***cpp=cp;
void main()
{
printf("%s",**++cpp);
printf("%s",*((*++cpp)-1)+3);
printf("%s",*cpp[-2]+3);
printf("%s",cpp[-1][-1]+1);}
char * str[ ] = {
american
created
which
david
bestow
}
Q7 Write a program to reverse a line using pointers
Q8 Write the function
which finds the string from in the string string and replaces it with the string to. You may
assume that from and to are the same length. For example, the code
(Extra credit: Think about what replace() should do if the from string appears multiple
times in the input string.)