牛客上编程中char一维数组/二维数组的输入和求长度C++

【c++】求问牛客上编程中char一维数组/二维数组的输入和求长度应该怎么写
最近总遇到输入和求长度不对的问题:
#include <iostream>
#include<stdio.h>
#include "string.h"
using namespace std;
int main()
{
char a[200];
cin >> a;
int a_len = 0;//a的长度
a_len = strlen(a);//!!!这里会报错,最后用的判断‘\0’解决的。求各位指教

全部评论
#include <cstring> #include <cstdlib> #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main() {     char a[200];     cin>>a;     int a_len=0;     a_len=strlen(a);     printf("%d",a_len);     return 0; }
点赞 回复 分享
发布于 2017-07-27 11:26
然而我的本地编译器VS2015可以顺利通过
点赞 回复 分享
发布于 2017-07-27 09:36
strlen遇到\0才停止,char a[]不是字符串,没有\0
点赞 回复 分享
发布于 2017-07-26 23:18
a里面全是\0吧
点赞 回复 分享
发布于 2017-07-26 23:03

相关推荐

白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务