//
// main.c
// cc
//
// Created by cclyy on 14-7-14.
// Copyright (c) 2014年 cclyy. All rights reserved.
//
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "string.h"
//结构体
//typedef struct _ren
//{
// int year;
// int month;
// int day;
// int sex;
//
// char name[16];
// char idcard[18];
//}Ren;
//
////typedef struct _ren Ren;
struct _Word
{
char word[64];
int tpye; //0 名词, 1 动词
struct _Word *ptNext;
};
typedef struct _Word Word;
int main ()
{
// Word ws[10];
//
// ws[0].tpye = 1;
// strcpy(ws[0].word, "abc");
//
// ws[1].tpye = 0;
// strcpy(ws[1].word, "abc");
Word *pWord = NULL;
pWord = (Word *)malloc(sizeof(Word));
pWord->tpye = 0;
strcpy(pWord->word, "test\0");
pWord->ptNext = NULL;
Word *pWord2 = NULL;
pWord2 = (Word *)malloc(sizeof(Word));
pWord2->tpye = 1;
strcpy(pWord2->word, "xxx\0");
pWord2->ptNext = NULL;
pWord->ptNext = pWord2;
printf("Hello, World!\n");
// int a = 123;
// int b = (int)&a;
// int c = (int)&b;
// int d = (int)&c;
//
// int e = *(&d);
//
// //指针
// int * f = &c;
//
// printf("a=%d, b=%d, c=%d, d=%d, e=%d, f=%d\n", a, b, c, d, e, (int)f);
//
// char c_a = 'A';
// char * c_b = &c_a;
//
// char c_c = *c_b;
//
// printf("%c, %c\n", c_a, c_c);
//
// char * c_1 = "ABCD\0EFG";
// printf("%s\n", c_1);
//
// printf("+4=%s\n", c_1 + 4);
// printf("+5=%s\n", c_1 + 5);
//
// printf("len=%d\n", (int)strlen(c_1));
// printf("sizeof=%d\n", (int)sizeof(c_1));
//
// int i = 0;
// while(i++ < 9)
// {
// // printf("===>[%d][%s]\n", (int)c_1, c_1);
// c_1++;
// }
//
//
// 打开文件
//int fd = open ( "/Users/cclyy/Desktop/c/cc/cc/123.txt" , O_RDONLY);
//printf("%d\n" , fd);
//char buffer[6] = {0};
//int rd = read (fd , buffer , 5 );
//printf("%d,%s\n" , rd ,buffer );
//打开文件并读取文件
// int n=1;
// int fd = open ( "/Users/cclyy/Desktop/c/cc/cc/123.txt" , O_RDONLY);
// char buffer[6] = {0};
// while (n!=0)
// {
// char buffer[6] = {0};
// int rd=read(fd, buffer, 5);
// n = rd;
// printf("%s" ,buffer );
// }
//
// close(fd);
// 创建文件
// int n=0;
// int fd =creat("/Users/cclyy/Desktop/c/cc/cc/456.txt", 0765);
// for (n=0 ; n<15; n++)
// {
// char buffer[4]={0};
// sprintf(buffer, "%d\n",n);
// printf("%d", n);
// write(fd, buffer, strlen(buffer));
// }
//
// close(fd);
// 更该文件属性
// chmod("/Users/cclyy/Desktop/c/cc/cc/456.txt",0777);
//
//
// int fd = open("/Users/cclyy/Desktop/c/cc/cc/1.txt", O_RDONLY);
// int n = 0;
// char *A = "abc";
// char buffer[1024] = {0};
// while (1)
// {
// int rd = read(fd, buffer , 3);
// if (rd == 0)
// {
// break;
// }
// if (buffer == A)
// {
// n++;
// }
//
//
// }
// printf("%d" , n);
//
//
// strstr 查找字符串
// int fd = open("/Users/cclyy/Desktop/c/cc/cc/1.txt", O_RDONLY);
// int n = 0;
// char *A = "bcdef";
// char buffer[1024] = {0};
// int rd = read(fd, buffer, 1024);
// char *xxx = buffer;
// while (1)
// {
// char* st=strstr(xxx, A);
// if (st==NULL) {
// break;
// }
// n++;
// xxx=st+1;
// }
//
// printf("%d", n);
//
// 结构体
// struct _ren xxx;
// Ren yyy;
// yyy.year = 1991;
// yyy.month = 11;
// yyy.day = 3;
// yyy.sex = 0;
// strcpy(yyy.name, "jcw");
// strcpy();
//
// FILE* fp = fopen("/Users/cclyy/Desktop/c/cc/cc/1.txt", "r");
// char buffer[1024]={0};
//
// while (1) {
// char *fg = fgets(buffer, 1024, fp);
//
// printf("[%d]", feof(fp));
// if (fg == NULL) {
// break;
// }
//
// printf("[%s]",buffer);
//
// }
// fclose(fp);
//
// printf("%d", (int)sizeof(Ren));
// malloc 申请固定内存
// char buf[6 * 1024 * 1024] = { 0 };
// printf("[%s]", buf);
//
// char *bigbuf = malloc(10 * 1024 * 1024);
// printf("[%s]", bigbuf);
//
//
// free(bigbuf);
//
// int fd = open("/Users/cclyy/Desktop/c/cc/cc/1.txt", O_RDONLY);
// int ls = lseek(fd, 0, SEEK_END);
// char *buffer = malloc(ls);
// lseek(fd, 0, SEEK_SET);
// int rd = read(fd, buffer, ls);
// printf("%d\n%d\n" , ls , rd);
// printf("%s" , buffer);
// free(buffer);
return 0;
}