给定一个字符串数组,我需要找出它中的字符串数。查找字符串的二维数组中的字符串数
我跟着this
,但如果我传递到这个函数,这并不工作。
这里就是我试图
#include<string>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int f1(char* input1[])
{
string s="";
cout<<sizeof(input1)<<endl; //print 4
cout<<sizeof(char*)<<endl; //print 4
int l=sizeof(input1)/sizeof(char*);
//giving l=1 here but should be 8
}
int main()
{
char *str2[]={"baba","sf","dfvf","fbfebgergrg","afvdfvfv","we","kkhhff","L"};
int l=sizeof(str2)/sizeof(char*);
cout<<l<<endl; //print 8
cout<<sizeof(str2)<<endl; //print 32
cout<<sizeof(char*)<<endl; //print 4
f1(str2);
}
你知道你必须解决这个问题的编译器吗? – MikeMB