佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1500|回复: 3

Arrays C++

[复制链接]
发表于 11-8-2010 12:43 AM | 显示全部楼层 |阅读模式
怎样可以把1-3的Character array放在弟4个?
请各位大大帮帮小弟。感激不尽!

=========================================================================
#include <iostream>
#include <cctype> //Needed for toupper function
#include <cstring> //Needed for string object
using namespace std;

int main()
{
char Name[10];
char No[7];
char Course[7];
char Output[24];

//Input from user
cout<< "Enter your first name: ";
cin>> Name;

cout<< "\nEnter your matric NO: ";
cin>> No;

cout<< "\nEnter your course: ";
cin>> Course;

//Store all the data
Output = Name + " - " + No + " - " + Course; <--Invalid

//Display data
for(int i=0;Output != '\0';i++)
Output= toupper(Output);
cout << Output << endl;

system("pause";

}
回复

使用道具 举报


ADVERTISEMENT

发表于 11-8-2010 04:19 PM | 显示全部楼层
c-string 那里可以用 +, 自己 google 一下 strcat
回复

使用道具 举报

发表于 17-8-2010 03:00 PM | 显示全部楼层
本帖最后由 felixwlchuan 于 18-8-2010 09:10 AM 编辑

strcat 或sprintf

较高级点就用memcpy
回复

使用道具 举报

发表于 31-12-2010 09:25 PM | 显示全部楼层
都说是C++ 了, 为什么还用array?  那些人花如此多心血开发STL,  岂不是对不住他们?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 15-11-2025 06:17 AM , Processed in 0.118837 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表