如何检测整数的长度?如果我有le:int test(234567545);
我怎么知道int有多长?比如告诉我里面有9个数字???
我试过了 :
char buffer_length[100];
// assign directly to a string.
sprintf(buffer_length, "%d\n", 234567545);
string sf = buffer_length;
cout <<sf.length()-1 << endl;
Run Code Online (Sandbox Code Playgroud)
但大部分都是更简单的方式或更干净......
你什么时候关闭线程怎么办?比如确保什么都没有打开或跑步?
到目前为止我知道如何打开它,但是......不是如何正确地关闭它
int iret1;
pthread_t thread1;
char *message1;
void *multithreading1( void *ptr ) {
while (1) {
// Our function here
}
}
int main (int argc, char * const argv[]) {
if( (iret1=pthread_create( &thread1, NULL, multithreading1, (void*) message1)) )
{
printf("Thread creation failed: %d\n", iret1);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 要在Mac和Windows之间处理特定于平台的代码,WIN32和APPLE是要使用的术语,对吗?
所以,代码看起来像这样:
#ifdef _WIN32
// Windows code
#endif
#ifdef __APPLE__
// Mac code
#endif
Run Code Online (Sandbox Code Playgroud)
Linux怎么样?
我怎么能为这三个人做到这一点?对
这段代码提供了一个点效果,就像一个加载栏("Loading.,Loading ..,Loading ..."),但问题是,只有一个单独的span id工作,第二个不会,我不知道为什么...请帮帮我们
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function showProgressDots(numberOfDots) {
var progress = document.getElementById('progressDots');
switch(numberOfDots) {
case 1:
progress.innerHTML = '.';
timerHandle = setTimeout('showProgressDots(2)',200);
break;
case 2:
progress.innerHTML = '..';
timerHandle = setTimeout('showProgressDots(3)',200);
break;
case 3:
progress.innerHTML = '...';
timerHandle = setTimeout('showProgressDots(1)',200);
break;
}
}
window.setTimeout('showProgressDots(1)',100);
//-->
</SCRIPT>
Loading<span id="progressDots" style="position:absolute;"></span>
SecondLoading<span id="progressDots" style="position:absolute;"></span>
Run Code Online (Sandbox Code Playgroud) 如何每10秒加载一个循环并为计数添加+1并打印它?
喜欢:
int count;
while(true)
{
count +=1;
cout << count << endl; // print every 10 second
}
Run Code Online (Sandbox Code Playgroud)
打印:
1
2
3
4
5
ect...
Run Code Online (Sandbox Code Playgroud)
我不知道怎么样,请帮帮我们
我知道,这bool
是在C++中使用,BOOL
而是Microsoft特定类型,被定义为int
.
我的代码正在使用,BOOL
因为它是为Windows开始的,但我正在尝试保持相同的方式,而不是将我的代码从BOOL
bool 更改为bool,当我将它移植到Mac时.
这样的事可以吗?
typedef int8_t _Bool;
typedef _Bool (BOOL);
static const BOOL False = 0;
static const BOOL True = 1;
Run Code Online (Sandbox Code Playgroud)
如果是的话,有更好的方法和原因吗?
如果没有,那么为什么以及我应该做什么呢?
此代码显示一个带有文本标签的窗口,上面写着:"请输入一个数字"和一个按钮.
单击按钮时,应将文本替换为"TEXT".它可以工作,但它会在第一个文本的顶部写入/打印新文本.所以它的重叠.
我想要更改文本字符串而不是写第一个,但我不知道我是如何对Windows应用程序开发的新手.
请帮帮我们.
整个来源是:
#include <windows.h>
#include <iostream>
using namespace std;
enum { ID_LABEL = 1,ID_BUTTON0};
static HWND static_label, button0;
HDC hdc;
HBRUSH NewBrush;
HINSTANCE g_hInst;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
LPCTSTR className = TEXT("myClass");
WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.lpszMenuName = NULL;
wc.lpszClassName = TEXT("myClass"); …
Run Code Online (Sandbox Code Playgroud) 如何使文字更大或div内的文字?
我真的不知道,帮帮我们
就像是:
$('div.text'), { FontSize: '40px' }); // <--- this is not real code, just to show what i need
Run Code Online (Sandbox Code Playgroud)