cÎļþ²Ù×÷
#include <stdio.h>
#include <stdlib.h> //use malloc, free
#include <string.h> //use memset
#include <ctype.h> //use isdigit
#define ERROR_ILLEGAL_CHAR 1 //define error illegal character as 1
#define ERROR_NUMBERS_DIF 2 //define error numbers is not the same in different line as 2
#define ERROR_FILE_ERROR 3 //define error file error as 3
typedef struct _node{
int num;
struct _node *next;
}node;
node *head = NULL;
void insert(int num)
{
if (NULL == head)
{
head = (node*)malloc(sizeof(node));
(*head).num = num;
(*head).next = NULL;
}
else
{
node* p = head;
while (NULL != p->next) //move to end
{
p = p->next;
}
p->next = (node*)malloc(sizeof(node));
p = p->next;
(*p).num = num;
(*p).next = NULL;
}
}
void output(int rows, int cols)
{
node *p = head;
if (NULL == p)
return;
for (int i=0; i<rows; i++)
{
for (int j=0; j<cols; j++)
{
printf("%-4d", p->num);
p = p->next;
}
printf("\n");
}
}
int getData(int *row, int *col)
{
FILE *f;
char ch = 0;
char t[100];
int index = 0;
int countline = 0;
int totalline = 0;
/*ÈôÎļþÄÚÈÝÊÇÔÚ³ÌÐòÖÐÒÔ¶þ½øÖÆ·½Ê½´ò¿ªÐ´ÈëµÄÊý¾ÝÔò½«´ò¿ª·½Ê½¸ÄΪ"rb"*/
if ((f=fopen("D:\\source\\read.dat", "r")) == NULL)
{
return ERROR_FILE_ERROR;
}
memset(t, -1, 100);
do
{
ch = fgetc(f);
if (isdigit(ch))
{
t[index++] = ch;
continue;
}
else
{
switch (ch)
{
case ',':
case '.':
case ' ':
if ((-1 != t[0]))
{
insert(atoi(t));
memset(t, -1, 100);
index = 0;
countline++;
}
break;
case EOF:
case '\n':
if ((-1 == t[0]) && (0 == countline))//null line
{
break;
}
else
{
if (-1 != t[0])
{
insert(atoi(t));
memset(t, -1, 100);
index = 0;
countline++;
}
}
if (0 != countline)
{
if (0 == totalline)
{
totalline = countline;
*col = totalline;
}
else
{
if (countline != totalline)
{
return ERROR_NUMBERS_DIF;
}
Ïà¹ØÎĵµ£º
DllImportËùÔÚµÄÃû×Ö¿Õ¼ä using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd);
private void button19_Click(obj ......
µ±Òª½»»»Á½¸öÊýµÄֵʱ£¬Í¨³£µÄ×ö·¨ÊǶ¨ÒåÒ»¸öÁÙʱ±äÁ¿£¬È»ºóÔÙ½øÐн»»»¡£ÄÇôÄܲ»Äܲ»ÓÃÁÙʱ±äÁ¿¶ø½»»»Á½¸öÊýµÄֵĨ£¿¿ÉÒԵģ¡CÓïÑÔÌṩµÄÒì»òÔËËã¾Í¿ÉÒÔʵÏÖÕâÑùµÄ²Ù×÷¡£
Òì»òÔËËã·û^Ò²³ÆXORÔËËã·û£¬ËüµÄ¹æÔòÊÇÈô²Î¼ÓÔËËãµÄÁ½¸ö¶þ½øÎ»Í¬ºÅ£¬Ôò½á¹ûΪ0£¨¼Ù£©£»ÒìºÅΪ1£¨Õ棩¡£¼´0 ^ 0 = 0, 0 ^ 1 = 1, 1 ^ 0 = 1, ......
c º¯ÊýÖ¸Õë
º¯ÊýÖ¸ÕëÊÇʲô£¿
Ò»¸öº¯ÊýÕ¼ÓÃÒ»¶ÎÁ¬ÐøÄÚ´æ¡£µ±µ÷ÓÃÒ»¸öº¯Êýʱ£¬Êµ¼ÊÉÏÊÇÌø×ªµ½º¯ÊýÈë¿ÚµØÖ·£¬Ö´Ðк¯ÊýÌåµÄ´úÂ룬Íê³Éºó·µ»Ø¡£
ÈçºÎÕÒµ½¶ÔÓ¦µÄÈë¿ÚµØÖ·£¿
ÕâÊÇÓɺ¯ÊýÃûÀ´±ê¼ÇµÄ£¬Êµ¼ÊÉÏ£¬º¯ÊýÃû¾ÍÊǺ¯ÊýµÄÈë¿ÚµØÖ·¡£ º¯ÊýÖ¸ÕëÊÇÒ»ÖÖÌØÊâÀàÐ͵ÄÖ¸Õë£¬Ë ......
ÔÚVC6ÖÐʹÓÃc API·½Ê½Á¬½ÓMySQLÊý¾Ý¿â
Ò»¡¢»·¾³ÅäÖÃ
1¡¢ÔÚMySqlµÄ¹Ù·½ÍøÕ¾ÏÂÔØmysql-connector-c-noinstall£¬²¢½«½âѹºóµÄbinºÍincludeÎļþ¼Ð¿½±´µ½MysqlµÄ°²×°Ä¿Â¼
2¡¢ÉèÖÃVC6»·¾³£¬ÔÚvc¹¤¾ß-Ñ¡Ïî-Ŀ¼£¬¼ÓÈë¸Õ²ÅµÄIncludeÎļþ¼ÐµÄ·¾¶£¬ÀýÈ磺C:\Program Files\MySQL\MySQL Server 5.1\include
¶þ¡¢¹¤³ÌÉèÖÃ
3¡¢½«li ......
To be continued...
µÚ8Õ UNIXϵͳ½Ó¿Ú
#include <stdio.h>
#include <fcntl.h>
#include "syscalls.h"
#defien PERMS 0666
void error(char *, ...);
/* cpº¯Êý: ½« f1 ¸´ÖƵ½ f2 */
int main(int argc, char *argv[])
{
int f1, f2, n;
char buf[BUFSIZ]; ......