注册 登录
编程论坛 C++教室

一些C++面试题求答案

战士 发布于 2008-06-04 09:26, 1162 次点击
char s[1000]="";
sizeof(s)=_;
strlen(s)=_;
strcpy(s,"abc");
sizeof(s)=_;
strlen(s)=_;
char s1[100]=s;
sizeof(s1)=;
strlen(s1)=_;
int i=-1;
unsiged j=i;
j=_;
Memorystate有什么作用?
下面的程序哪里有错误?
void  first()
{
 char *p=0;
 two(p);
}
void two(char *j)
{
 *j=2;
 }
int i=3;
int j=i<<3;
i=_;
j=_;
c++中怎么连接sql数据库?
先想到这么多,以后再想到再发。

[[it] 本帖最后由 战士 于 2008-6-4 09:30 编辑 [/it]]
3 回复
#2
zzy8402082008-06-04 12:44
做了前面一些
char s[1000]="";
sizeof(s)=1000;//分配了1000个字节给s,一个字符占一个字节
strlen(s)=0;   //s中不存在任何字符,所以为0;

strcpy(s,"abc");
sizeof(s)=1000;//分配给s的空间没有变化,还是1000个字节
strlen(s)=3;   //赋了三个字符给它,所以它的长度为3个字节

char s1[100]=s;//不存在这样的初始化,可以改为:
               //char s1[100];
               //strcpy(s1,s);
sizeof(s1)=100;//分配了100个字节给s1
strlen(s1)=3;  //s1中有三个字符了
#3
六道2008-06-04 16:50
楼上正解~
连接AQL:ADO,DAO,ODBC

应该是指针初始化和作用域方面的问题

i=3
i为0000 0011左移3位0001 1000,所以j=24

[[it] 本帖最后由 六道 于 2008-6-4 17:02 编辑 [/it]]
#4
六道2008-06-04 16:55
MEMORYSTATUS
This structure contains information about current memory availability. The GlobalMemoryStatus function uses this structure.
当前内存可用的一些信息。

typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORD dwTotalPhys;
DWORD dwAvailPhys;
DWORD dwTotalPageFile;
DWORD dwAvailPageFile;
DWORD dwTotalVirtual;
DWORD dwAvailVirtual;
} MEMORYSTATUS, *LPMEMORYSTATUS;
Members
dwLength
Specifies the size, in bytes, of the MEMORYSTATUS structure. Set this member to sizeof(MEMORYSTATUS) when passing it to the GlobalMemoryStatus function.
dwMemoryLoad
Specifies a number between 0 and 100 that gives a general idea of current memory utilization, in which 0 indicates no memory use and 100 indicates full memory use.
dwTotalPhys
Indicates the total number of bytes of physical memory.
dwAvailPhys
Indicates the number of bytes of physical memory available.
dwTotalPageFile
Indicates the total number of bytes that can be stored in the paging file. Note that this number does not represent the actual physical size of the paging file on disk.
dwAvailPageFile
Indicates the number of bytes available in the paging file.
dwTotalVirtual
Indicates the total number of bytes that can be described in the user mode portion of the virtual address space of the calling process.
dwAvailVirtual
Indicates the number of bytes of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process.

[[it] 本帖最后由 六道 于 2008-6-4 16:56 编辑 [/it]]
1