#include<string.h>
main()
{
char arr1[9]={'w','e','l','','c','o','m','e'};
char arr2[9]="welcome";
char arr3[9]={{'w'},{'e'},{'l'},{''},{'c'},{'o'},{'m'},{'e'}};
clrscr();
pf("\narray1=%s",arr1);
pf("\narray2=%s",arr2);
pf("\narray3=%s",arr3);
}
output :-
array1= wel come
array2= welcome
array3= wel come
example for counting elements :-
#include<string.h>
main()
{
char text[17]="RANDOM ACCESS";
clrscr();
printf("%s\n",text);
printf("%.5s\n",text);
printf("%.8s\n",text);
printf("%.15s\n",text);
printf("%17s\n",text);
printf("%-10.4s\n",text);
getch();
}
output :-
RANDOM ACCESS
RANDO
RANDOM A
RANDOM ACCESS
RANDOM ACCESS
RANDOM ACC
main()
{
char arr1[9]={'w','e','l','','c','o','m','e'};
char arr2[9]="welcome";
char arr3[9]={{'w'},{'e'},{'l'},{''},{'c'},{'o'},{'m'},{'e'}};
clrscr();
pf("\narray1=%s",arr1);
pf("\narray2=%s",arr2);
pf("\narray3=%s",arr3);
}
output :-
array1= wel come
array2= welcome
array3= wel come
example for counting elements :-
#include<string.h>
main()
{
char text[17]="RANDOM ACCESS";
clrscr();
printf("%s\n",text);
printf("%.5s\n",text);
printf("%.8s\n",text);
printf("%.15s\n",text);
printf("%17s\n",text);
printf("%-10.4s\n",text);
getch();
}
output :-
RANDOM ACCESS
RANDO
RANDOM A
RANDOM ACCESS
RANDOM ACCESS
RANDOM ACC
0 comments:
Post a Comment