#
#include<stdio.h>
void func(char str[100]);
int main()


{

char str[] = "fasfsdge";
char* p = str;
int n = 10;

printf("%d\n",sizeof(str));
printf("%d\n",sizeof(p));
printf("%d\n",sizeof(n));

func(str);

return 0;
}

void func(char str[100])


{
printf("%d\n",sizeof(str));
}
#include<stdio.h>
#include<memory.h>

int main()


{
int num = 0;
while(1)

{
printf("請輸入矩陣每邊的數(shù)字個(gè)數(shù)(個(gè)數(shù)必須大于1的奇數(shù)):");
scanf("%d",&num);
if(num>1 && num%2 == 1)

{
break;
}
else

{
printf("個(gè)數(shù)必須是大于1的奇數(shù)\n");
}
}

int *matrix = new int[num*num];

memset(matrix,0,num*num*sizeof(int));

int row = 0,col = 0;
row = 0;
col = (num-1)/2;
int i = 1;

while( i <= num*num)

{
if(col<0)

{
col = col+num;
}
col = col%num;
if(row<0)

{
row = row+num;
}
row = row%num;

if(matrix[row*num+col] != 0)

{
row +=2;
col--;
}
else

{
matrix[row*num+col]= i;
row--;
col++;
i++;
}
}

int ii = 0,jj =0;
for(; ii*num+jj<num*num; jj= ++jj%num)

{
if(jj == num-1)

{
printf("%d\n",matrix[ii*num+jj]);
ii++;
}
else

{
printf("%d\t",matrix[ii*num+jj]);
}
}

return 0;
}
void func(int m,int n)


{
int a[m*n];
int a[0] =9;
}

int main()


{
func(5,4);
return 0;
}
//上面的編譯無法通過
#include<stdio.h>

int main()


{

int *p = (int*)malloc(sizeof(int)*50);
for(int i = 0; i<50; i++)

{
*(p+i) = i+2;
}

int * q =p;
++q;

printf("value is %d\n",*p);
printf("value is %d\n",*q);
printf("value is %d\n",*(p+49));
printf("value is %d\n",*(q+49));

free(p);

printf("value is %d\n",*p);
printf("value is %d\n",*q);
printf("value is %d\n",*(q+1));
printf("value is %d\n",*(q+2));

return 0;
}


#include<stdlib.h>
#include<memory.h>
#include<string.h>
#include<stdio.h>

int func(void)


{
static int i = 0;
return ++i;
}


int a = 0;
char *p1;
int main()


{

int b ;
char s[]= "abc";
char *p2;
char *p3 ="123456";
static int c = 0;
p1 = (char*)malloc(10);
p2 = (char*)malloc(20);

int *p = &a;
p = &b;
p = &c;

strcpy(p1,"123456");

int i;
i = func();
i= func();

printf("%d\n",i);

return 0;
}
//使用VC內(nèi)存察看來觀察
摘要: //tcpsever.cpp#include"targetver.h"#define WIN32_LEAN_AND_MEAN#include<windows.h>#include<commctrl.h>#include<tchar.h>#include<winsock2.h>#include"resource.h"#include<s...
閱讀全文
// mfctime.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//

#include "stdafx.h"
#include "mfctime.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// 唯一的應(yīng)用程序?qū)ο?/span>

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])


{
int nRetCode = 0;

// 初始化 MFC 并在失敗時(shí)顯示錯(cuò)誤
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

{
// TODO: 更改錯(cuò)誤代碼以符合您的需要
_tprintf(_T("錯(cuò)誤: MFC 初始化失敗\n"));
nRetCode = 1;
}
else

{
// TODO: 在此處為應(yīng)用程序的行為編寫代碼。
time_t t;
time(&t);
tm *newtime;
newtime = localtime(&t);

printf("%s",asctime(newtime));


//C++寫法
SYSTEMTIME tt;
GetLocalTime(&tt);

CString str;
str.Format(_T("%u/%u/%u %u:%u:%u:%u"),
tt.wYear, tt.wMonth, tt.wDay,
tt.wHour, tt.wMinute, tt.wSecond,
tt.wMilliseconds);

LPTSTR lpsz = new TCHAR[str.GetLength()+1];
_tcscpy(lpsz, str);
wprintf(L"%s",lpsz);


}

return nRetCode;
}

如果參數(shù)是'0'到'9',那么返回非0,否則返回0
#include<stdio.h>
#include<string.h>

int main()


{
//找出后串在前串中的匹配的第一個(gè)指針。
char *str1 = "hdhgjgf";
char *str2 ="dh";
char *p = 0;
p = strstr(str1,str2);

printf("%s",p);
return 0;
}
#include<string.h>
#include<stdio.h>
int main()


{
FILE *pFile;
pFile = fopen("myfile.txt","w+");

char str[8] = "qwertyu";
fwrite(str,1,7,pFile);

long pos = ftell(pFile);

char ch = getc(pFile);

int ret = 0;

ret = printf("%d",pos);
ret = printf("%c",ch);

ret = fseek(pFile,-5,2);

if(ret != 0)

{
printf("wrong");
}
pos = ftell(pFile);
ch =getc(pFile);
ret = printf("%d",pos);
ret = printf("%c",ch);

char strbuf[6];
//rewind(pFile);
ret = fread(strbuf,1,3,pFile);

printf("%s",strbuf);

fclose(pFile);
return 0;

}