Bài 2:

Post date: Dec 7, 2011 6:49:04 AM

Yêu cầu: Viết chương trình sử dụng con trỏ trỏ đến các chuỗi để nhận tên của một con thú và một con chim và trả về các tên theo dạng số nhiều (thêm s).

Hướng dẫn:

#include<stdio.h>

#include<string.h>

void main()

{

char animal[30],bird[30];

char ani_plural[30],bird_plural[30];

char *an, *bi;

an=animal;

bi=bird;

printf("Enter the name of the animal : ");

scanf("%s",an);

printf("Enter the name of the bird : ");

scanf("%s",bi);

strcpy(ani_plural,strcat(an,"s"));

printf("\nPlural of animal is %s",ani_plural);

strcpy(bird_plural,strcat(bi,"s"));

printf("\nPlural of bird is %s",bird_plural);

getch();

}