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

c/c++ string


1.±¾ÕÂ˼άµ¼Í¼£º



Example1:
char
*strcpy(char *target, const char *source) {
  char *t = target;

  // Copy the contents of source into target.
 
while(*source) *target++ = *source++;
  // Null-terminate the
target.
  *target = '\0';
  // Return pointer to the
start of target.
  return t;
}
Example2:
void
*memmove(void *target, const void *source, size_t count)
Õâ¸öº¯Êý¼´Ê¹
ÊÇÔÚÔ´ºÍÄ¿µÄ×Ö·û´®ÓÐËùÖØµþʱ²Ù×÷Ò²Äܳɹ¦£¬ËäÈ»sourceΪconst£¬µ«ÊÇÆäÖ¸ÏòµÄarrayÒ²¿ÉÄܱ»Ð޸ġ£
2.
CÐÍ×Ö·û´®²Ù×÷ʵÀý£º
Ex1.»ù±¾²Ù×÷
/*
*

=====================================================================================

*
*       Filename:  2-1.cpp
*
*   
Description:  Fundamental Operations in C Type String
*
*       
Version:  1.0
*        Created:  05/11/2010 10:43:11 AM
*      
Revision:  none
*       Compiler:  gcc
*
*        
Author:  gnuhpc (http://blog.csdn.net/gnuhpc)
,
warmbupt@gmail.com
*        Company:  IBM CDL
*
*

=====================================================================================

*/
#include 
#include 
using namespace std;
int main(int argc, char *argv[])
{

    char strA[7]="UP";
    char strB[5]="DOWN";
   
char strC[5]="LEFT";
    char strD[6]="RIGHT";
   
/*Display */
    cout << "Here are the strings: " <<
endl;


Ïà¹ØÎĵµ£º

½»»»Á¬¸ö¶ÔÏóµÄÖµ£¨C/C++?JAVA£©

ÈçºÎ½»»»Á½¸ö±äÁ¿µÄÖµ£º
CÓïÑÔÖеĴ«Öµ´úÂëÈçÏ£º
int change(int x,int y)
{
int temp=x;
x=y;
y=temp;
}
CÓïÑÔÖеĴ«Ö·´úÂëÈçÏ£º
int change(int *p,int *q)
{
int temp=*p;
*p=*q;
*q=temp;
}
ʹÓÃC++ÖеÄÒýÓÃÀàÐÍ´úÂëÈçÏÂ:
int change(int &x,int &y)
{
int temp=x;
x=y;
y=temp;
}
JAV ......

C/C++ÄÚ´æ·ÖÅä


#include <iostream>
using namespace std;
void main()
{
 char *p,*q;
 p = "abcde";
 q = p + 3;
 *q = 't';
 cout<<p<<endl;
 cout<<q<<endl;
}
Á½ÖÖÓïÑÔ±àÒë¶¼¿ÉÒÔͨ¹ý
µ±Ö´Ðе½
 *q = 't';
ʱ£¬C++³ÌÐò³öÏÖÄÚ´æ·ÃÎÊ´íÎó£¬C³ÌÐò¿ÉÒ ......

¼òÊöCºÍC++µÄѧϰÀú³Ì(תФô´ÀÏʦ)

×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
Ò»¼ÒÖ®ÑÔ£¬»¶Ó­ÅÄש¹þ¡£
1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC¡£
´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²» ......

c/c++Í·Îļþ£¬±£´æ£¬±¸ÓÃ

 
C¡¢´«Í³ C++
#include <stdio.h>¡¡¡¡¡¡¡¡ //¶¨ÒåÊäÈ룯Êä³öº¯Êý
#include <stdlib.h>¡¡¡¡¡¡¡¡//¶¨ÒåÔÓÏÊý¼°ÄÚ´æ·ÖÅ亯Êý
#include <string.h>¡¡¡¡¡¡¡¡//×Ö·û´®´¦Àí
#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h&g ......

cÊä³ö±ê×¼×ܽá

  CÊä³ö¸ñʽ×ܽá ÊÕ²Ø
CÊä³ö¸ñʽ×ܽá
 
1 Ò»°ã¸ñʽ
   printf(¸ñʽ¿ØÖÆ£¬Êä³ö±íÁУ©
   ÀýÈ磺printf("i=%d,ch=%c\n",i,ch);
   ˵Ã÷:
   (1)“¸ñʽ¿ØÖÆ”ÊÇÓÃ˫ƲºÅÀ¨ÆðÀ´µÄ×Ö·û´®£¬Ò²³Æ“ת»»¿ØÖÆ×Ö·û´®”£¬Ëü°üÀ¨Á½ÖÖÐÅÏ¢£º
 &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ