C知识点累积篇

1. __DATE__

The compilation date of the current source file. The date is a string literal of the formMmm dd yyyy. The month nameMmm is the same as for dates generated by the library functionasctime declared in TIME.H. 

__TIME__

The most recent compilation time of the current source file. The time is a string literal of the formhh:mm:ss

例子:

#include<time.h>
#include<stdio.h>

int main()
{
        char strmsg[200];
        sprintf(strmsg,"INF:Compile Date %s Time %s",__DATE__, __TIME__);
        printf("%s\n",strmsg);
}

2.返回关于文件属性的结构体  类似Linux的basename

#define _WIN32_WINNT 0x0400

#include "windows.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;

  printf ("Target file is %s.\n", argv[1]);

  hFind = FindFirstFile(argv[1], &FindFileData);

  if (hFind == INVALID_HANDLE_VALUE) {
    printf ("Invalid File Handle. Get Last Error reports %d\n", GetLastError ());
  } else {
    printf ("The first file found is %s\n", FindFileData.cFileName);
    FindClose(hFind);
  }

  return (0);
}

3.#ifdef __cplusplus 有什么作用?

一般用于将C++代码以标准C形式输出(即以C的形式被调用),这是因为C++虽然常被认为是C的超集,但是C++的编译器还是与C的编译器不同的。C中调用C++中的代码这样定义会是安全的。
一般的考虑跨平台使用方法如下:
#ifdefined(__cplusplus)||defined(c_plusplus) //跨平台定义方法
extern "C"{
#endif
//... 正常的声明段
#ifdefined(__cplusplus)||defined(c_plusplus)
}
#endif 


简单的用在windows下可以如下定义:
#ifdef   __cplusplus
extern "C"{
//... 正常的声明段
}
#endif


SendMessage该函数将指定的消息发送到一个或多个窗口。此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回。而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值