Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(7)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæÐ¡±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1.       fgetcº¯Êý
fgetcº¯ÊýµÄ¹¦ÄÜÊÇ´ÓÁ÷ÖжÁÈ¡×Ö·û£¬ÆäÓ÷¨ÊÇ£ºint fgetc(FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   FILE *stream;
   char string[] = "This is a test";
   char ch;
   /* open a file for update */
   stream = fopen("DUMMY.FIL", "w+");
   /* write a string into the file */
   fwrite(string, strlen(string), 1, stream);
   /* seek to the beginning of the file */
   fseek(stream, 0, SEEK_SET);
   do
   {
      /* read a char from the file */
      ch = fgetc(stream);
      /* display the character */
      putch(ch);
   } while (ch != EOF);
   fclose(stream);
   return 0;
}
2.       fgetcharº¯Êý
fgetcharº¯ÊýµÄ¹¦ÄÜÊǹرմò¿ªÁ÷£¬ÆäÓ÷¨ÊÇ£ºint fgetchar(void); ³ÌÐòÀý×ÓÈçÏ£º
#include <stdio.h>
int main(void)
{
   char ch;
   /* prompt the user for input */
   printf("Enter a character followed by \
   <Enter>: ");
   /* read the character from stdin */
   ch = fgetchar();
   /* display what was read */
   printf("The character read is: '%c'\n",
          ch);
   return 0;
}
3.       freadº¯Êý
freadº¯ÊýµÄ¹¦ÄÜÊÇ´ÓÒ»¸öÁ÷ÖжÁÊý¾Ý£¬ÆäÓ÷¨ÊÇ£ºint fread(void *ptr, int size, int nitems, FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h>
#include <stdio.h>
int main(void)
{
   FILE *stream;
   ch


Ïà¹ØÎĵµ£º

pku 2115 C Looooops ͬÓඨÀí

 #include <stdio.h>
long long mod(long long a,long long b)
{
return (a % b + b) % b;
}

struct triple
{
long long d,x,y;
};

long long Euclid(long long a,long long b)
{
if(b == 0)
return a;
else
retu ......

Á´±íµÄ»ù±¾²Ù×÷(cʵÏÖ£©

  
Á´±í¶¨Òå¼°²Ù×÷µÄÔ´Îļþ£ºemployee.h
//
#pragma once
#ifndef __EMPLOYEE_H__
#define __EMPLOYEE_H__
#include<stdio.h>
#include<malloc.h>
typedef struct employee{
int id;
int age;
int salary;
}EmpType;
typedef struct Node{
EmpType data;
struct Node *next;
}L ......

CÓïÑÔÁ¬½ÓmysqlÊý¾Ý¿â£¬¶ÁÈ¡mysqlÄÚÈÝ

 //linuxϱàÒëg++ $(mysql_config --cflags)  ***.cpp  $(mysql_config --libs)
/*mysqlÊý¾Ý¿âÖбíµÄÄÚÈÝ
mysql> select * from maindb;
+------------------+---------+-------------+---------+----------+---------------------+---------------------+---------------------+------------------- ......

curl c api

 curl c api
¹ØÓÚCurlµÄ½éÉܺܶ࣬ÕâÀï²»Ïêϸ½éÉÜ£¬Ö÷Ҫ̸һϼòµ¥Ó¦Óá£
×î½üÑо¿ÁËÒ»ÏÂLinuxϵÄcurl C API,curl c APIµÄÎĵµ±È½Ï·á¸»£¬Î¨Ò»¾ÍÊDzéÕÒÆðÀ´£¬·ÑЩʱ¼ä¡£CurlµÄC APIºÍcurlµÄPHP API£¬º¯Êý½Ó¿ÚºÍ×÷ÓôóÖÂÏàͬ£¬ËùÒÔÈç¹ûÓÐPHP APIʹÓþ­ÑéÓ¦¸ÃºÜºÃÀí½â¡£
1£ºCURLcode curl_global_init(long flags);º¯ ......

extern "C"Ïê½â

 Ê±³£ÔÚcppµÄ´úÂëÖ®Öп´µ½ÕâÑùµÄ´úÂë: 
#ifdef __cplusplus 
extern "C" { 
#endif 
//Ò»¶Î´úÂë 
#ifdef __cplusplus 

#endif 
¡¡¡¡ÕâÑùµÄ´úÂëµ½µ×ÊÇʲôÒâË¼ÄØ£¿Ê×ÏÈ£¬__cplusplusÊÇcppÖеÄ×Ô¶¨Òåºê£¬ÄÇô¶¨ÒåÁËÕâ¸öºêµÄ»°±íʾÕâÊÇÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ