字符数组

来源:互联网 发布:编程入门书籍 编辑:程序博客网 时间:2024/05/16 16:10
01./*  02.* 程序的版权和版本声明部分:  03.* Copyright (c) 2011, 烟台大学计算机学院  04.* All rights reserved.  05.* 文件名称:test.cpp  06.* 作    者:刘芳07.* 完成日期:201 3年12 月 8日  08.* 版 本 号:v1.0  09.* 对任务及求解方法的描述部分: 10.* 输入描述:无  11.* 问题描述: 12.* 程序输出: 13.* 问题分析:略 14.* 算法设计:略  15.*/    

#include <iostream>#include<string>using namespace std;int main(){    void smallest_sting(char str[][30],int i);    int i;    char country_name[3][30];    for(i=0;i<3;i++)    cin>>country_name[i];    smallest_sting(country_name,3);    return 0;}void smallest_sting(char str[][30],int n){    int i;    char sting[30];    strcpy(sting,str[0]);    for(i=0;i<n;i++)    if(strcmp(str[i],sting)<0)    strcpy(sting,str[i]);    cout<<endl<<"the smallest sting is:"<<sting<<endl;}

用strcpy,strcmpy要提前声明????
原创粉丝点击