dc rectangle

請看看這道題怎么做?#include
using namespace std;
class rectangle
{
int x1;
int y1;
int x2;
int y2;
public:
rectangle()
{
x1=0;
y1=0;
x2=0;
y2=0;
}
void set(int A_x,int A_y,int B_x,int B_y)
{
this->x1=A_x;
this->y1=A_y;
this->x2=B_x;
this->y2=B_y;
}
void put()
{
cout<<"The rectangle of girth is"<<((x2-x1)+(y2-y1))*2<<endl;
cout<<"The rectangle of area is"<<(x2-x1)*(y2-y1)<<endl;
}
};
int main()
{
rectangle rect;
int a,b,c,d;
cout<<"please input rectangle of coord:"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
rect.set(a,b,c,d);
rect.put();
}

解答下面的題目18 D,都可以 。19,序列化 。從mfc的基類CObject就支持序列化了 。20 。一定要選一個的話只能勉強算B吧 。如1樓所說,函數名錯了,應該是Rectangle

高手幫忙看看這段C++class Rectangle{ private:point LeftTop,rightBottom;public:Rectangle(int x1,int y1,int x2,int y2):LeftTop(x1,y1),rightBottom(x2,y2){ }}其相應修改;

編程題,急用#include
using namespace std;

class rectangle
{
public:
// rectangel(int x1,int y1,int x2,int y2):X1(x1),Y1(y1),X2(x2),Y2(y2){}
int s(int ,int ,int ,int);
private:
int X1,Y1;
int X2,Y2;
};
int rectangle::s(int a1,int b1,int a2,int b2)
{int S;
S=(a1-a2)*(b1-b2);
return S;

}
int main()
{int x1, y1, x2,y2,c;
cout<<"請依次輸入兩點的坐標:"<<endl;
cin>>x1>>y1>>x2>>y2;
rectangle A;
c=A.s(x1,y1,x2,y2);
cout<<"面積:"<<c<<endl;
return 0;
}

C++大神來,求解1.定義class后面忘了“;”class A { };
2.mianji()的返回值為float,
void Rectangle::mianji()
{
float temp1,temp2;
if(x1>x2) temp1=x1-x2;
else temp1=x2-x1;
if(y1>y2) temp2=y1-y2;
else temp2=y2-y1;
return (temp1*temp2);
}

這里你寫成void了

class Rectangle{ double left ,top; double right,bottom; public: Rectangle(int l=0,int t=0,int r=0,in你這代碼有一半沒一半的..
自己新建個記事本把內容粘貼進去然后重命名記事本 把名字改成rect.h就可以了 記住勾上顯示后綴名 要么怎么改名字都是記事本

left left right right是不是"兔子舞"的啊?
left left right right go turn around go go go
left right left left right right
left left right right go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left right left left right right
left left right right go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
Jumping grooving dancing everybody
Rooling moving singing night&day
Let's fun fun together
Let's play the penguing's games
Smacking beating clapping all together
Rocking bumping screaming all night long
Let's go everybody And play again this song
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left left right right go turn around go go go
left right left left right right
left left right right go go go

crect類里的left , top ,right , bottom分別是這個矩形的什么坐標?(x0, y0),(x1, y1)-->(left, top),(right, bottom)
其中(x0, y0)是這個矩形區域的左上角,(x1, y1)是這個矩形區域的右下角 。只要這兩個點確定了,這個矩形區域就被唯一確定下來 。謝謝

有一首歌的歌詞大概是這樣的:left,left,right,right…… 請問這首歌的名字叫啥?兔子舞...

關于塊級元素的四個屬性left right top bottom的問題您好 這四個屬性是定位屬性,當然是要和定位結合起來才能使用了,定位屬性position值有以下幾種值描述1、absolute生成絕對定位的元素,相對于 static 定位以外的第一個父元素進行定位 。元素的位置通過 "left", "top", "right" 以及 "bottom" 屬性進行規定 。2、fixed生成絕對定位的元素,相對于瀏覽器窗口進行定位 。元素的位置通過 "left", "top", "right" 以及 "bottom" 屬性進行規定 。3、relative生成相對定位的元素,相對于其正常位置進行定位 。因此,"left:20" 會向元素的 LEFT 位置添加 20 像素 。4、static默認值 。沒有定位,元素出現在正常的流中(忽略 top, bottom, left, right 或者 z-index 聲明) 。5、inherit規定應該從父元素繼承 position 屬性的值 。希望我的回答能幫到您
c++中的類,比如CRect,這是一個類嗎?很顯然是一個類,在MFC中,以C(class)開頭的都是類名;
CRect m_rect; 是聲明一個成員變量,這個成員變量時個矩形的區域!

建議先學C++再看MFC;

希望對你有幫助,純手打~

友元函數與類內部的成員函數有什么不同最根本的區別:友元函數沒有這個類的對象的this指針,只能通過顯式參數修改類的對象,類內部的成員函數有一個這個類的對象的this指針作為隱式參數,因此成員函數需要以foo.bar()的形式調用,而友元函數需要以bar(foo)的形式調用……

c++難題,左思右想想不出來 類和對象類,指的是一個抽象的定義
對象,是這個類實例化的一個東西
舉個例子:我在一個程序中需要有20個人,那么首先我就要定義什么是人,定義好的人,就是一個類,但是我程序不是要知道什么是人,而是需要20個人,所以我就要實例化20個人這個類,那么實例化出來的20個,就是對象

Java定義一個Rectangle類class Rectangle { private double width; private double height; public Rectangle(double width, double height) {this.width = width;this.height = height; } public double getC() {return (width + height) * 2; } public double getS() {return width * height; } public double getWidth() {return width; } public void setWidth(double width) {this.width = width; } public double getHeight() {return height; } public void setHeight(double height) {this.height = height; }}public class Test { public static void main(String[] args) {Rectangle rect = new Rectangle(4, 5);System.out.println("周長=" + rect.getC() + "\n面積=" + rect.getS()); }}

VC中CRect類的簡介類CRect是對Windows結構RECT的封裝,凡是能用RECT結構的地方都可以用CRect代替 。
結構RECT表示一個矩形的位置和尺寸,其定義為:
typedef struct tagRECT{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
其中 left、top分別表示矩形左上角頂點的橫坐標和縱坐標,right、bottom分別表示矩形右下角頂點的橫坐標和縱坐標 。由于CRect提供了一些成員函數和重載運算符,使得CRect的操作更加方便 。1.CRect的構造函數 CRect有如下6個構造函數:
CRect( );
CRect( int l, int t, int r, int b );
CRect( const RECT& srcRect );
CRect( LPCRECT lpSrcRect );
CRect( POINT point, SIZE size );
CRect( POINT topLeft, POINT bottomRight );
說明:分別以不同的方式構造CRect對象,參數l,t,r,b分別指定矩形的左邊、上邊、右邊和底邊 。SrcRect是一個RECT結構的引用 。LpSrcRect是一個指向RECT結構的指針 。Point指定矩形的左上角頂點的坐標,size指定矩形的長度和寬度 。topLeft指定矩形的左上角頂點的坐標,bottomRight指定矩形的右下角頂點的坐標 。

求高手指導C語言中rectangle函數的用法函數原型:BOOL Rectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)


hdc:設備環境句柄 。nLeftRect:指定矩形左上角的邏輯X坐標 。nTopRect:指定矩形左上角的邏輯Y坐標 。nRightRect:指定矩形右下角的邏輯X坐標 。nBottomRect:指定矩形右下角的邏輯Y坐標 。

C語言,rectangle() ZeroMemory()這兩個函數不太理解 求高人指點一下簡單用法 及格式...The Rectangle function draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush.

BOOL Rectangle(
HDC hdc,// handle to DC
int nLeftRect,// x-coord of upper-left corner of rectangle
int nTopRect,// y-coord of upper-left corner of rectangle
int nRightRect,// x-coord of lower-right corner of rectangle
int nBottomRect// y-coord of lower-right corner of rectangle
);

繪指導下一個矩形,從屏幕的左上方(nLeftRect, nTopRect)到右下方(nRightRect,nBottomRect)

void ZeroMemory(
PVOID Destination,
SIZE_T Length
);

將分配數組置0

c語言中strcmp的用法

dc rectangle

文章插圖

strcmp是比較兩個字符串的大小,兩個字符串相同時返回0,第一個字符串大于第二個字符串時返回一個正值,否則返回負值 。比較兩個字符串的算法是:逐個比較兩個串中對應的字符,字符大小按照ASCII碼值確定,從左向右比較,如果遇到不同字符,所遇第一對不同字符的大小關系就確定了兩個字符串的大小關系,如果未遇到不同字符而某個字符串首先結束,那么這個字符串是較小的,否則兩個字符串相等 。擴展資料:C語言主要有以下特點:1、C語言在很多方面都可以用,不僅僅是在軟件開發上,各類科研都是需要用到C語言的 。具體應用比如我是學硬件的,單片機以及嵌入式系統都可以用C來開發 。2、C是結構式語言結構式語言的顯著特點是代碼及數據的分隔化, 即程序的各個部分除了必要的信息交流外彼此獨立 。這種結構化方式可使程序層次清晰, 便于使用、維護以及調試 。C 語言是以函數形式提供給用戶的, 這些函數可方便的調用, 并具有多種循環、條件語句控制程序流向, 從而使程序完全結構化 。3、C語言功能齊全C 語言具有各種各樣的數據類型, 并引入了指針概念, 可使程序效率更高 。另外C 語言也具有強大的圖形功能, 支持多種顯示器和驅動器 。而且計算功能、邏輯判斷功能也比較強大, 可以實現決策目的編游戲,編3D游戲,做數據庫,做聯眾世界,做聊天室,做PHOTOSHOP做FLASH,做3DMAX 。
solidrectangle函數是什么意思Rectangle是長方形的意思,同時也是一個函數,使用該函數畫一個矩形,可以用當前的畫筆畫矩形輪廓,用當前畫刷進行填充 。
函數原型:
BOOL Rectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
參數:
hdc:設備環境句柄 。
nLeftRect:指定矩形左上角的邏輯X坐標 。
nTopRect:指定矩形左上角的邏輯Y坐標 。
nRightRect:指定矩形右下角的邏輯X坐標 。
nBottomRect:指定矩形右下角的邏輯Y坐標 。
返回值:如果函數調用成功,返回值非零,否則返回值為0 。
Windows NT:若想獲得更多錯誤信息,請調用GetLastError函數 。
備注:此函數不使用和改變當前位置 。
速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:1.0及以上版本;頭文件:wingdi.h;庫文件:gdi32.lib 。
示例:
Rectangle(hdc,0,0,100,100);

C語言中的 setlinestyle和rectangleSOLID_LINE 實線 THICK_WIDTH 線條寬度的設置
rectangle四個參數是兩個點的坐標 即矩形左上角點的坐標和右下角點的坐標,用來確定矩形區域的大小

html5怎么實現繪制矩形嵌套矩形估計你是初學者吧,當時我學習的時候也有過這種疑問 。這些內容在css里面會講到的 。
這樣就可以了 。
其實等你學到css以后就全明白了努力學習吧

MFC 繪制矩形時怎么清除上一個矩形MFC手冊里面的類應該有這個功能對應的成員函數啊 。不行去MSDN問問吧 。

MFC 畫一個透明矩形向設備上下文dc選入一個空畫刷br和一個紅畫筆pen即可
簡單實例如下:
//CBrush br;
//CPen pen;
pen.CreatePen(PS_SOLID,1,RGB(255,0,0));
br.CreateStockObject(NULL_BRUSH);

dc.SelectObject(&pen);
dc.SelectObject(&br);

//dc.Rectangle(1,1,100,100);

如何畫一個矩形,然后可以移動和刪除它在WORD和EXCEL中,畫一個矩形很簡單 。下面以WORD為例(WORD和EXCEL的繪圖操作是一樣的) 。調出一個繪圖工具欄,在工具欄上可以找到“矩形”按鈕 。點擊按鈕,在WORD空白處點左鍵不放,拖動鼠標,然后可以放開 。如何移動呢?先點擊矩形邊框線,出現如上圖狀態(我稱之為被選中狀態),左鍵點矩形框的線條不放,拖動鼠標,即可把矩形拖到你想要放的位置了 。如何刪除?點擊矩形邊框線,出現如上圖狀態,按DELETE鍵或BACKSPACE鍵,均可刪除此矩形 。如果你問的不是WORD,EXCEL的,可以繼續追問 。能幫到你的就幫 。
MFC繪制矩形在MFC中畫矩形Visual Studio 2008
//首先創建一個MFC工程,名為:Rectangle,在界面上放置一個picture control的控件,其關聯變量為:m_showRectangle 。

//然后添加鼠標事件,OnLButtonDown,OnLButtonUp,OnMouseMove

//BOOL lButtonDownNotUp=FALSE;

//CPoint regionLeftTopTemp;

//CPoint regionRightBottomTemp;

void CRectangleDlg::OnLButtonDown(UINT nFlags, CPoint point)
{

lButtonDownNotUp = TRUE;
RECT rect;
m_showRectangle. GetClientRect( &rect ) ;

if( (point. xrect. left) && (point. yrect. top) )
{
regionLeftTopTemp = point;
}

CDialog::OnLButtonDown(nFlags, point);
}



void CRectangleDlg::OnMouseMove(UINT nFlags, CPoint point)
{

RECT rect;
m_showRectangle. GetClientRect( &rect );
if( ( point.xrect.left ) && ( point.yrect.top ) )
{
if( ( lButtonDownNotUp == TRUE )
{
regionRightBottomTemp = point;
CDC * pDC = m_showRectangle. GetWindowDC ();

pDC -> Rectangle( CRect( regionLeftTopTemp, regionRightBottomTemp ) ) ;
}
}

CDialog::OnMouseMove(nFlags, point);
}


void CRectangleDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
lButtonDownNotUp=FALSE;
CDialog::OnLButtonUp(nFlags, point);
}

vc++中繪制rectangle(100,100,20,50)什么意思?畫一個矩形,不過坐標反了,不建議這樣使用(當然,也能畫出來,橫20~100縱50~100)

VC Rectangle如何去邊框選個空的筆到DC去,Rectangle用當前筆畫邊框的.

vc++中繪制ellipse、LineTo、rectangle,個代表什么意思?第一個,橢圓,第二個,線段,第三個,矩形 前兩個數是矩形左上角的x,y后兩個數是矩形右下角的x,y

C 語言 圖形圖像問題小問題只要游戲控制流暢,坦克做成方塊也是沒問題的 。一般來說,都是加載圖片,然后通過putimage這樣的語句快速顯示圖片 。
用圖片做開始菜單背景一樣的道理,通過加載圖片 。不過既然是學習編程,不如嘗試用程序畫一個背景 。
vc6下用graphics.h只需要下載easyx并安裝就行了 。

C#中怎樣畫矩形以及怎樣獲得窗口的Height和WidthtextBox1.Text = this.Width.ToString();//獲得當前窗口的寬度
textBox2.Text = this.Height.ToString();//獲得當前窗口的高度
Graphics g = Graphics.FromHwnd(this.Handle);
g.DrawRectangle(Pens.Blue, 10, 10, 100, 200);//創建一個藍色的空心矩形

畫圖主要是使用Graphics類和Draw方法,打開MSDN查查看就知道怎么寫了 。

C++向窗口繪制矩形MFC的繪圖類其實是對Windows GDI API的封裝,目前發展到GDI+,其實直接使用GDI+也是相當強大的,我給你介紹一下怎么使用windows的GDI+吧:

(1)準備使用GDI+ 的API
#include
#include
using namespace Gdiplus;

VOID Example_DrawRectangle(HDC hdc)
{ // 參數hdc為繪圖設備上下文句柄,你可以用GetDC()之類的函數獲取
Graphics graphics(hdc); // 構造一個graphics對象,然后繪圖就引用此對象方法即可繪圖,真是厲害

Pen blackPen(Color(255, 0, 0, 0), 3);
Rect rect(0, 0, 200, 200); // 矩形
graphics.DrawRectangle(&blackPen, rect); // 繪制一個矩形
}

一個矩形窗戶,它的寬與高的比值是根號5—1:2,那么該怎樣畫出這個長方形?在數軸上選2cm,垂直這條線段做一個1cm長線段形成一個直角,連接兩點做一個直角三角形 。斜邊為根號5,減去1CM,得根號5-1 。垂直此線段做2CM,至此,兩邊做出 。平行兩邊做平行線得矩形 。

cad2007畫矩形的問題,在窗口中怎么切換輸入下一個數據,如圖:輸入"逗號",就可以在動態框中輸入200了.

如何在CAD三維窗口中畫垂直的兩個矩形在視圖里面改變視角再畫,或者用ucs改變xy平面的方向,當我們打開圖紙畫一個正方形(A)后,將其UCS坐標的XY平面變成垂直于正方形(A)的平面,然后進行繪制正方向(B)就可以畫出兩個互相垂直的正方形了 。。。不用UCS,也可以用視圖中的俯視圖,左視圖,右視圖....這些去畫,畫好了在視圖中點個西南(東南,西北,西南)等軸測方向就能看到效果了.

mfc rectangle只能畫灰色的么?rectangle可以畫為任何顏色的,用CBrush(畫刷)和CPen(畫筆)設置一下顏色就可以了 。

MFC 如何指定一個矩形并填充顏色CRect rt(200,200,500,600);pDC->FillSolidRect(&rt,RGB(255,0,0));//紅色填充

MFC里面畫矩形 ,怎么改變矩形邊框顏色?CPen pen(PS_SOLID,1,RGB(255,0,0));
dc.SelectObject(&pen);

MFC 繪制矩形時怎么清除上一個矩形?1、繼承CWnd函數:InvalidateRect(NULL);UpdateWindow();2\更多交流參考我空間文章 。

C++ MFC 如何畫一個有透明填充色的矩形,求代碼// 假設已經有了一個 CDC *pDC// 獲取一個透明畫刷,并將其選入設備描述表CBrush *pBrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));CBrush *pOldBrush = pDC->SelectObject(pBrush);// 使用 CDC::Rectangle 函數繪制矩形,略// 還原設備描述表pDC->SelectObject(pOldBrush);

c語言的bar()函數和 rectangle()函數bar函數
功 能: 畫一個二維條形圖
用 法: void far bar(int left,int top,int right,int bottom);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT,gmode,errorcode;
int midx,midy,i;
/* initialize graphics and local variables */
initgraph(&gdriver,&gmode,"");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n",grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit⑴; /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* loop through the fill patterns */
for (i=SOLID_FILL; i<USER_FILL; i++)
{
/* set the fill style */
setfillstyle(i,getmaxcolor());
/* draw the bar */
bar(midx-50,midy-50,midx+50,
midy+50);
getch();
}
/* clean up */
closegraph();
return 0;
}

rectangle函數
功 能: 畫一個矩形
用 法: void far rectangle(int left, int top, int right, int bottom);
參數說明:(left ,top )為矩形的左上坐標,(right,bottom)為矩形的右下坐標,兩者可確定一個矩形的大小
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
left = getmaxx() / 2 - 50;
top = getmaxy() / 2 - 50;
right = getmaxx() / 2 + 50;
bottom = getmaxy() / 2 + 50;
/* draw a rectangle */
rectangle(left,top,right,bottom);
/* clean up */
getch();
closegraph();
return 0;
}

請教大家關于MATLAB中關于regionprops和rectangle函數的用法同問啊 。。我也在想這個問題 。。

C#中兩個參數為RectangleF的函數A矩形相對于B矩形的位置 。
A矩形的X坐標減去B矩形的X坐標,A矩形的Y坐標減去Y矩形的X坐標 。

public PointF RelativePosition(RectangleF recA, RectangleF recB)
{
PointF point = new Point();
point.X = recA.X - recB.X;
point.Y = recA.Y - recB.Y;
return point;
}

請教ZeroMemory()函數The ZeroMemory function fills a block of memory with zeros.

VOID ZeroMemory(
PVOID Destination,// memory block
SIZE_T Length// size of memory block
);
Parameters
Destination
[in] Pointer to the starting address of the block of memory to fill with zeros.
Length
[in] Size, in bytes, of the block of memory to fill with zeros.

上面是MSDN中的解釋,就是說這個函數實現的功能是將Destination制定的內存地址開始,Length字節長度的內存數據清零 。

C語言中清空字符串的庫函數
dc rectangle

文章插圖

字符串函數在頭文件中定義了兩組字符串函數 。第一組函數的名字以str開頭;第二組函數的名字以mem開頭 。只有函數memmove對重疊對象間的拷貝進行了定義,而其他函數都未定義 。比較類函數將其變量視為unsigned char類型的數組 。1.strcpy#include char *strcpy(char *str1, const char *str2);把字符串str2(包括'\0')拷貝到字符串str1當中,并返回str1 。2. strncpy#include char *strncpy(char *str1, const char *str2, size_t count);把字符串str2中最多count個字符拷貝到字符串str1中,并返回str1 。如果str2中少于count個字符,那么就用'\0'來填充,直到滿足count個字符為止 。3.strcat#include char *strcat(char *str1, const char *str2);把str2(包括'\0')拷貝到str1的尾部(連接),并返回str1 。其中終止原str1的'\0'被str2的第一個字符覆蓋 。4.strncat#include char *strncat(char *str1, const char *str2, size_t count);把str2中最多count個字符連接到str1的尾部,并以'\0'終止str1,返回str1 。其中終止原str1的'\0'被str2的第一個字符覆蓋 。注意,最大拷貝字符數是count+1 。5.strcmp#include int strcmp(const char *str1, const char *str2);按字典順序比較兩個字符串,返回整數值的意義如下:小于0,str1小于str2;等于0,str1等于str2;大于0,str1大于str2;6 strncmp#include int strncmp(const char *str1, const char *str2, size_t count);同strcmp,除了最多比較count個字符 。根據比較結果返回的整數值如下:小于0,str1小于str2;等于0,str1等于str2;大于0,str1大于str2;7 strchr#include char *strchr(const char *str, int ch);返回指向字符串str中字符ch第一次出現的位置的指針,如果str中不包含ch,則返回NULL 。8 strrchr#include char *strrchr(const char *str, int ch);返回指向字符串str中字符ch最后一次出現的位置的指針,如果str中不包含ch,則返回NULL 。9 strspn#include size_t strspn(const char *str1, const char *str2);返回字符串str1中由字符串str2中字符構成的第一個子串的長度 。10 strcspn#include size_t strcspn(const char *str1, const char *str2);返回字符串str1中由不在字符串str2中字符構成的第一個子串的長度 。11 strpbrk#include char *strpbrk(const char *str1, const char *str2);返回指向字符串str2中的任意字符第一次出現在字符串str1中的位置的指針;如果str1中沒有與str2相同的字符,那么返回NULL 。12 strstr#include char *strstr(const char *str1, const char *str2);返回指向字符串str2第一次出現在字符串str1中的位置的指針;如果str1中不包含str2,則返回NULL 。13 strlen#include size_t strlen(const char *str);返回字符串str的長度,'\0'不算在內 。14 strerror#include char *strerror(int errnum);返回指向與錯誤序號errnum對應的錯誤信息字符串的指針(錯誤信息的具體內容依賴于實現) 。15 strtok#include char *strtok(char *str1, const char *str2);在str1中搜索由str2中的分界符界定的單詞 。對strtok()的一系列調用將把字符串str1分成許多單詞,這些單詞以str2中的字符為分界符 。第一次調用時str1非空,它搜索str1,找出由非str2中的字符組成的第一個單詞,將str1中的下一個字符替換為'\0',并返回指向單詞的指針 。隨后的每次strtok()調用(參數str1用NULL代替),均從前一次結束的位置之后開始,返回下一個由非str2中的字符組成的單詞 。當str1中沒有這樣的單詞時返回NULL 。每次調用時字符串str2可以不同 。如:char *p;p = strtok("The summer soldier,the sunshine patriot", " ");printf("%s", p);do {p = strtok("\0", ", "); /* 此處str2是逗號和空格 */if (p)printf("|%s", p)} while (p);顯示結果是:The | summer | soldier | the | sunshine | patriot
求一個用C語言編寫的小游戲代碼/*也不知道你是什么級別的,我是一個新手,剛接觸編程語言,以下是我自己變得一個小程序,在所有c語言的編譯器(vc++6.0、turbo…………)上都能運行,你還可以進一步改進 。這是一個類似貪吃蛇的小游戲 。祝你好運*/
/*貪吃蛇*/
#include
#include
#include
#include
int head=3 ,tail=0;
int main()
{
int i,j,k=0;
int zuobiao[2][80];
long start;
int direction=77;
int gamespeed;
int timeover;
int change(char qipan[20][80],int zuobiao[2][80],char direction);
zuobiao[0][tail]=1;zuobiao[1][tail]=1;zuobiao[0][1]=1;zuobiao[1][1]=2;zuobiao[0][2]=1;zuobiao[1][2]=3;zuobiao[0][head]=1;zuobiao[1][head]=4;
/*處理棋盤*/
char qipan[20][80];//定義棋盤
for(i=0;i<20;i++)
for(j=0;j<80;j++)
qipan[i][j]=' ';//初始化棋盤
for(i=0;i<80;i++)
qipan[0][i]='_';
for(i=0;i<20;i++)
qipan[i][0]='|';
for(i=0;i<20;i++)
qipan[i][79]='|';
for(i=0;i<80;i++)
qipan[19][i]='_';
qipan[1][1]=qipan[1][2]=qipan[1][3]='*';//初始化蛇的位置
qipan[1][4]='#';
printf("This is a game of a SNAKE.\nGOOD LUCK TO YOU !\n");
printf("Input your game speed,please.(e.g.300)\n");
scanf("%d",&gamespeed);

while(direction!='q')
{
system("cls");
for(i=0;i<20;i++)//打印出棋盤
for(j=0;j<80;j++)
printf("%c",qipan[i][j]);
timeover=1;
start=clock();
while(!kbhit()&&(timeover=clock()-start<=gamespeed));
if(timeover)
{
getch();
direction=getch();
}
else
direction=direction;
if(!(direction==72||direction==80||direction==75||direction==77))
{
return 0;
system("cls");
printf("GAME OVER!\n");
}
if(!change(qipan,zuobiao,direction))
{
direction='q';
system("cls");
printf("GAME OVER!\n");
}
}
return 0;
}
int change(char qipan[20][80],int zuobiao[2][80],char direction)
{
int x,y;
if(direction==72)
x=zuobiao[0][head]-1;y=zuobiao[1][head];
if(direction==80)
x=zuobiao[0][head]+1;y=zuobiao[1][head];
if(direction==75)
x=zuobiao[0][head];y=zuobiao[0][head]-1;
if(direction==77)
x=zuobiao[0][head];y=zuobiao[1][head]+1;
if(x==0||x==18||y==78||y==0)
return 0;
if(qipan[x][y]!=' ')
return 0;
qipan[zuobiao[0][tail]][zuobiao[1][tail]]=' ';
tail=(tail+1)%80;
qipan[zuobiao[0][head]][zuobiao[1][head]]='*';
head=(head+1)%80;
zuobiao[0][head]=x;
zuobiao[1][head]=y;
qipan[zuobiao[0][head]][zuobiao[1][head]]='#';
return 1;
}

c語言中字符串清空的函數是什么?【dc rectangle】方法1:使用運行庫函數memset():
memset(str, 0, sizeof(str));

方法2:使用Windows API函數ZeroMemory():
ZeroMemory(str, sizeof(str));

但不能用于指針 。指針的情況下,必須這樣:
struct mystr {.......} *p;
...
memset(p, 0, sizeof(struct mystr));
或:
ZeroMemory(p, sizeof(struct mystr));