我知道 32 位机器可以访问的内存大小限制为 4GB。由于还需要处理 PCIe、USB、串行、并行、PS/2、音频 I/O、CD 驱动器、软驱、存储卡读卡器等 I/O 端口,结果是小于CPU 本身支持 4GB RAM。我刚才提到的所有事情和其他事情也需要相当多的记忆。
现在让我困惑的是它如何支持几GB的硬盘空间?它如何能够通过这些 SATA/ATA 接口访问甚至高达 1 TB 的外部存储。USB大容量存储设备如外置USB硬盘也是如此,我很惊讶CPU可以访问如此大的存储空间,同时被限制为32位。32位处理器可以支持多大的硬盘没有限制吗?
这是程序:
#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
const char c[] = "C:\\Users\\*.*";
hFind = FindFirstFile(c, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf("FindFirstFile failed (%d)\n", GetLastError());
return 1;
}
else
{
cout << "The first file found is " << FindFileData.cFileName << endl;
}
for (int i = 0; i < 12; i++)
{
if (!FindNextFile(hFind, &FindFileData))
{
printf("FindNextFile failed (%d)\n", GetLastError());
}
else
{
cout << "The next file found …Run Code Online (Sandbox Code Playgroud) std::hex 导致放入流中的数据被打印为十六进制值。但是,用于表示数字 10 到 15 的字母 AF 总是以小写字母出现。有没有办法将其更改为使用大写字母?
Python提供了日志记录模块。我们可以使用记录器代替打印并使用其多个日志级别。这里的问题是,当我们使用记录器时,我们将日志字符串传递到记录器对象中。这意味着记录器对象必须可以从整个 Python 程序中的每个函数/方法和类访问。
logger = logging.getLogger('mylogger')
logger.info('This is a message from mylogger.')
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,对于可能分为多个源文件并由多个函数/方法和类组成的大型 Python 程序,我们如何确保在任何地方都使用相同的记录器对象来记录消息?或者我对如何使用日志记录模块有错误的想法?
背景:我试图澄清C中指针和动态内存分配的谜团.我试图从用户那里获得几个浮点输入,将它们存储在一个动态分配的数组中,从而扩展以容纳更多的值.一旦用户输入0,循环终止并计算和打印总和和平均值.我正在使用Borland C 5.02
问题:1.循环仅工作4次,然后第4个值未存储!
2.如果我用x [i]和*(x + i-1)用x [i-1]替换x + i,我得到"浮点错误:堆栈错误""异常程序终止.
int main(void)
{
float *x;
float sum=0;
float avg=0;
int i=0;
x=(float*)malloc(sizeof(float));
do
{
scanf("%f",x+i); //take input
i++;
x=(float*)realloc(x, i*sizeof(float)); //reallocate memory to store more values
if(x==NULL){printf("WARNING");}
printf("\n%f %p %d\n",*(x+i-1),x,i);
}while(*(x+i-1)!=0);
for(int j=0;j<i;j++)
{sum=sum+*(x+j);} // Sum all values
avg=sum/(i-1); //Find result, i is 1 bigger than number of values, ith value is 0
printf("\n\n%d sum: %f avg: %f ",i,sum,avg);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 这是我的程序,因为它最少重现错误:
#include <iostream>
#include <Windows.h>
#include <fstream>
using namespace std;
#define iwidth 5;
#define iheight 3;
int main()
{
struct rgb_data_struct {
BYTE B;
BYTE G;
BYTE R;
};
rgb_data_struct **image;
image = new rgb_data_struct *[iwidth];
for (int i = 0; i < iwdith; i++)
{
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,我在主函数中使用iwdith,它用红色曲折线加下划线.将鼠标悬停在"错误:预期a']'"上
编译会产生以下错误:
Error 1 error C2143: syntax error : missing ')' before ';' c:\users\user0\documents\cpp\bitmap\bitmap\main.cpp 51 1 bitmap
Error 2 error C2143: syntax error : missing ']' before ')' c:\users\user0\documents\cpp\bitmap\bitmap\main.cpp 51 …Run Code Online (Sandbox Code Playgroud) 这就是我想要做的:
const char wav_folder[] = ".\\wav";
const char search_path[strlen(wav_folder) + 6];
Run Code Online (Sandbox Code Playgroud)
但是strlen部分不允许我创建这个字符数组.这不是编译.为什么?
错误:
Error 1 error C2057: expected constant expression c:\users\hassan\documents\cpp\dir_search\dir_search\dir_search\source.cpp 15 1 dir_search
Error 2 error C2466: cannot allocate an array of constant size 0 c:\users\hassan\documents\cpp\dir_search\dir_search\dir_search\source.cpp 15 1 dir_search
Error 3 error C2734: 'search_path' : const object must be initialized if not extern c:\users\hassan\documents\cpp\dir_search\dir_search\dir_search\source.cpp 15 1 dir_search
Error 4 error C2133: 'search_path' : unknown size c:\users\hassan\documents\cpp\dir_search\dir_search\dir_search\source.cpp 15 1 dir_search
Run Code Online (Sandbox Code Playgroud) 我在上次采访中被问到这个问题并再次期待它.采访是针对嵌入式系统编程的固件工程师.可用于这些应用的微处理器和微控制器通常不是很强大,而较简单的微控制器和微控制器没有能力进行浮点计算(内部没有乘法器或分频器).
那么这个问题的可能答案是什么,以及定点运算与此有什么关系?
是否可以使用Newton-Raphson方法进行此计算?怎么样?
我对异常很新.在我的程序的一部分中,如果某个特定变量超出某个值,我想手动抛出一个异常,该异常会说该变量超出了可接受的范围.变量为16位仍然可以保持"无效"值,但在正常的程序操作下,它只能保存它可以保存的可能值的子集.
如何生成此特定类型的异常?
我需要编写一个函数将数据转移到输入向量中。输入的类型可以是有符号或无符号的。为了使函数更加稳健,我需要知道输入向量的方向,即使用 downto 与 to 声明的范围。此信息将用于确定哪个索引具有最低有效位。
如何查明范围是如何声明的,并根据该信息选择正确的最低有效位和最高有效位?