c++ - Globally declared char array is ambiguous when passed on to the function
问题描述
Here's my code I am new to stack exchange so kindly ignore any silly mistakes when I try to compile this program it says that the array is ambiguous I really don't know what to do please help
#include <array>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
char array[2];
void format(int number, int width,char* array);
int main(void)
{
int number,width;
cout<<"write a number:"<<endl;
cin>>number;
cout<<"write width:"<<endl;
cin>>width;
format(number,width,char(&array)[2]);
}
void format(int number, int width,char* array)
{
int numofzeros;
int length = (int)(log10(number)+1);
numofzeros=width-length;
if(width<length)
{
cout<<number<<endl;
}
}
解决方案
推荐阅读
- git - 是否可以使用 NextCloud 下载私有文件夹和 SVN 来下载一些带有 dotdrop 的 dotfiles 的私有特定文件?
- git - 如何告诉 git 专门为一组文件保留 CRLF?将文本文件标记为二进制文件?
- .net-core - System.Configuration.ConfigurationManager.ConnectionStrings 在运行时检索旧值
- after-effects - 在 After Effects 中将表达式简化为值
- java - GarbageCollector 在将 XX:MaxMetaspaceSize 设置为相同的旧 XX:MaxPermSize 值后停止运行
- macos - 采购错误文件 .zshrc 而不是 init.vim 时如何重置 vim 和 neovim
- python - 尝试编写一个程序来检查列表中每个字符串中的字符数
- flutter - 请帮助我了解 PreferredSize 调试
- git - 为应用程序开发功能并传达更改
- firebase - 与反应原生 Firebase 身份验证模块的奇怪用户连接