C/C++ 与运算和或运算转换大小写
// & 与,将指定位置设置为0 | 或,将指定位置设置为1
//注: 只针对纯字母的情况
#include <stdio.h>
#include <string>
int main()
{
char str[6] = "xxing";
std::string str1 = "INGXX";
for(int i = 0; i < 5; i++)
{
str[i] &= 0xdf;// 转大写 1101 1111
str1[i] |= 0x20;// 转小写 0010 0000
}
printf("xxing:%s\nINGXX:%s\n", str, str1.c_str());
return 0;
}
相关文档:
C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick
Share | ......
C/C++函数调用约定和函数名称修饰规则探讨
作者:星轨(oRbIt)
使用C/C++语言开发软件的程序员经常碰到这样的问题:有时候是程序编译没有问题,但是链接的时候总是报告函数不存在(经典的LNK
2001错误),有时候是程序编译和链接都没有错误,但是只要调用库中的函数就会出现堆栈异常。这些现象通常是出现在C和C ......
利用
下载的这段代码,成功实现了守护进程,原来守护进程是很简单的事情。
在main函数中执行
init_daemon();//初始化为Daemon
就可以把进程变成守护进程
#include
#include
#include
#include
#include
void
init_daemon(void
)
{
int
pid;
int
i;
if
(pid=fork()) ......
1、在C文件中调用C++文件中定义的文件
直接的方法是在C++ 文件的头部添加如下代码段:
extern "C"
{
int API(int A);
}
2、C++接口的方法
在C++中调用C的函数,在C头文件中加入如下代码:
#ifdef __cplusplus // 开始
exte ......