c primer plus Ò»µÀÁ·Ï°Ì⣬ÇóÖú - C/C++ / CÓïÑÔ
ÌâÄ¿ÊÇ£º±àдһ¶Î³ÌÐò£¬ÒÀ´ÎÔÚÆÁÄ»ÉÏÏÔʾÃüÁîÐÐÖÐÁгöµÄËùÓÐÎļþ¡£Ê¹ÓÃargc¿ØÖÆÑ»·
£¨Write a program that sequentially displays onscreen all the files listed in the command line. Use argc to control a loop.£©
¼¸ºõÊÇÕÕ³ÍøÉϵÄÁ·Ï°Ô´´úÂ룬µ«½á¹ûÊÇ´íµÄ
C/C++ code:
1 #include <stdio.h>
2 #include <stdlib.h>
3
4
5 int main(int argc,char *argv[])
6 {
7 int byte;
8 FILE *source;
9 int filect;
10
11 if(argc==1)
12 {
13 printf("Usage: %s filename[s]\n",argv[0]);
14 exit(EXIT_FAILURE);
15 }
16
17 for(filect=1;filect<argv;filect++)
18 {
19 if((source=fopen(argv[filect],"r"))==NULL)
20 {
21 printf("Counld not open file %s for input\n",argv[filect]);
22 continue;
23 }
24
25 while((byte==getc(source))!=EOF)
26 {
27 putchar(byte);
28 // putc(byte,stdout);
29 }
30
31 if(fclose(source)!=0)
32 {
33 printf("Counld not close file %s\n",argv[1]);
34 }
35 }
36 return 0;
ubuntuÏÂÔËÐнá¹ûΪ
C/C++ code
��������������ʏ
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ͦ·±Ëö£¬Ö®Ç°·¢µÄÌû×Ó£¬·Öֵ̫µÍÏÖÔÚÖØ·¢Ò»¸ö¡£»¶Ó¸÷λ´óÏÀ~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......
ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë
Äã²»Àí½âÖ ......
ÈçºÎ½«Ò»¸öListBoxÖеÄÊý¾Ý´æÔÚÊý¾Ý¿âÖеÄÒ»¸ö×Ö¶ÎÏÂÃ棬²¢ÇÒÿÌõ¼Ç¼µÄ×Ö·û´®¸öÊý²»Ò»¶¨ ÒÔ¼°ÈçºÎ´ÓÊý¾Ý¿âÖжÁÈ¡¸ÃListBoxÖеÄËùÓмǼ
C/C++ code:
//´æÈëÊý¾Ý¿â
void __fastcall TForm1::Button5Click(TO ......