我正在编程课上学习2D数组。我的老师使用了一些东西而没有解释它,我很好奇为什么我们使用它。由于它与符号有关,因此我不确定如何在Google上搜索或搜索它,因为这些符号用于搜索本身。无论如何,代码是这样的:
int small[26]= {0}, large[26]={0}, i;
为什么在0周围需要花括号?
该代码是该程序的一部分,它检查文件并查找字母表中的每个字母并分别进行计数。
所以我有这么简单的代码.它应该做的是从华氏温度计算摄氏度.然而,出于某种原因,它会将分值重置为0.任何人都可以解释为什么这样做?我敢肯定我只是错过了一些小而愚蠢的东西.
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main (void)
{
ofstream fout("temps.dat");
float fahr=0, avgcent=0, avgfahr=0, totalcent=0, totalfahr=0, gettemp=0;
double cent = ((5/9) * (fahr - 32));
const int gatekeeper=-99999;
fout << setw(25) << "Fahrenheit" << setw(20) << "Centigrade" << endl << endl;
fout.setf(ios :: fixed);
fout.setf(ios :: showpoint);
cout << "Please input Fahrenheit temp (-99999 to quit)" << endl;
cin >> fahr;
while (fahr != gatekeeper)
{
totalfahr = totalfahr + fahr;
totalcent …Run Code Online (Sandbox Code Playgroud) 在哪里使用 TextOut 或 DrawText?
TCHAR text[]= "My First Window";
RECT rc;
HDC wdc = GetWindowDC(hWnd);
GetClientRect (hWnd, &rc);
SetTextColor(wdc, 0x00000000);
SetBkMode(wdc,TRANSPARENT);
rc.left=40;
rc.top=10;
TextOut(hdc,rc.left,rc.top,text,ARRAYSIZE(text));
EndPath(hdc);
SelectClipPath(hdc, RGN_AND);
Run Code Online (Sandbox Code Playgroud)
我把这个放在WM_CREATE:
结果是一个空白窗口。如果需要,我可以提供更多代码,但这只是一个标准的 Win32 空白窗口。
这是我的第一个真正的 Win32 应用程序,我用 google 搜索了一个小时,但没有找到问题的答案。
谢谢