C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(16)
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. qsortº¯Êý
qsortº¯ÊýµÄ¹¦ÄÜÊÇʹÓÿìËÙÅÅÐòÀý³Ì½øÐÐÅÅÐò£¬ÆäÓ÷¨Îª£ºvoid qsort(void *base, int nelem, int width, int (*fcmp)());³ÌÐòʵÀýÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_function( const void *a, const void *b);
char list[5][4] = { "cat", "car", "cab", "cap", "can" };
int main(void)
{
int x;
qsort((void *)list, 5, sizeof(list[0]), sort_function);
for (x = 0; x < 5; x++)
printf("%s\n", list[x]);
return 0;
}
int sort_function( const void *a, const void *b)
{
return( strcmp(a,b) );
}
2. putwº¯Êý
putwº¯ÊýµÄ¹¦ÄÜÊÇ°ÑÒ»×Ö·û»ò×ÖË͵½Á÷ÖУ¬ÆäÓ÷¨Îªint putw(int w, FILE *stream);³ÌÐòʵÀý´úÂëÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
#define FNAME "test.$$$"
int main(void)
{
FILE *fp;
int word;
fp = fopen(FNAME, "wb");
if (fp == NULL)
{
printf("Error opening file %s\n", FNAME);
exit(1);
}
word = 94;
putw(word,fp);
if (ferror(fp))
printf("Error writing to file\n");
else
printf("Successful write\n");
fclose(fp);
fp = fopen(FNAME, "rb");
if (fp == NULL)
{
printf("Error opening file %s\n", FNAME);
exit(1);
}
word = getw(fp);
if (ferror(fp))
printf("Error reading file\n");
else
&nbs
Ïà¹ØÎĵµ£º
ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏֵġ£ClientÊÇÀûÓÃServerÌṩµÄÌض¨·þÎñµÄ³ÌÐò£¬Server½ÓÊÜÀ´ÖÁClientµÄÇëÇóÏûÏ¢²¢Í¬²½»òÒì²½µ ......
unzip.c
ÖÐÒýÓÃvalidate.cpp
ÎļþÖеĺ¯ÊýÀ´½øÐÐepub
¾À´í£¬²úÉúµÄÎÊÌ⣺
1.
validate.cpp
ÖÐʹÓÃiostream.h,
µ«ÊÇC
ÖÐûÓÐÕâ¸öÎļþ
£¬ËùÒÔ²úÉúµÄ´íÎó£º
2>
ÕýÔÚ±àÒë...
2>unzip.c
2>D:\Program
Files\VC\include\cstdio(25) : error C2143:
Óï·¨´íÎó:
ȱÉÙ“{ ......
VC.NETÖеÄStringÀàÊÇÀûÓÃUnicode×Ö·û¼¯±àÂëÀ´±íʾÎı¾¡£Unicode×Ö·û¼¯ÖÐÿ¸ö×Ö·û(ºº×Ö¡¢Ó¢ÎÄ×Öĸ)¶¼Õ¼2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔ2¸öÁ¬ÐøµÄ\0½áβµÄ¡£
ANSIµÄASCII×Ö·û¼¯ÊÇ×î³£¼ûµÄ×Ö·û¼¯£¬³£ÓÃÓÚ±íʾtxtµÄÎı¾Îļþ¡£ÔÚASCII×Ö·û¼¯ÖÐÓ¢ÎÄÕ¼Ò»¸ö×Ö½Ú£¬ºº×Ö2¸ö×Ö½Ú£¬ÇÒÆä×Ö·û´®ÊÇÒÔÒ»¸ö\0½áβµÄ¡£
ÔÚÀûÓÃVC.NET½øÐлìºÏ±à³Ìʱ ......
5¡¢#defineºê¶¨Òå¡£ºêÖ»ÊǼòµ¥µÄÎı¾Ìæ»»£¬ºÜÈÝÒ×ÒýÆðÆçÒå¡£
#include <stdio.h>
#define CONS(a,b) (int)(a##e##b)
#define STR(s) #s
int main()
{
printf(STR(vck));
printf("\n");
printf("%d\n",CONS(2,3));
return 0; ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. mallocº¯Êý
mallocº¯ÊýµÄ¹¦ÄÜÊÇÄÚ´æ·ÖÅ亯Êý£¬ÆäÓ÷¨Îª£ºvoid *malloc(unsigned size);³ÌÐòʵÀýÈçÏ£º
#include <stdio.h>
#i ......