Câu 1.17: Viết hàm tính độ dài xâu ký tự (không sử dụng hàm chuẩn strlen). Viết chương trình nhập vào từ bàn phím xâu ký tự s, áp dụng hàm trên in ra màn hình độ dài của xâu vừa nhập?

Monday, August 11, 2014
// cbai17.cpp : Defines the entry point for the console application.
// code Dung NV

#include "stdafx.h"
#include <conio.h>
#include <stdio.h>
int dodaixau(char s[])
{
                int i=0;
                while (s[i]!='\0') i++;
                return i;
}

int _tmain(int argc, _TCHAR* argv[])
{
                char s[100];
                printf("Nhap vao mot xau ki tu: ");
                gets(s);
                printf("Do dai xau vua nhap la: %d",dodaixau(s));
                getch();
                return 0;

}
Chia sẻ bài viết ^^
Other post

All comments [ 0 ]


Your comments