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

cºÍc++ÏÂÓÃջʵÏÖÊýµÄ½øÖÆ×ª»»

1. CµÄʵÏÖ
//stack.h
#ifndef STACK_H
#define STACK_H
#define STACK_CAPACITY 20//maximum size of stack
typedef int stackEle;
typedef struct
{
stackEle myArray[ STACK_CAPACITY ];
int myTop;
}stack;
//construct(initialize) an empty stack
stack *stack_init(void);
//return 1 if stack is empty and 0 otherwise
int empty(stack *);
//retrieve top element of the stack
stackEle top(stack* );
//add an element at the top of the stack
void push(stack*,stackEle);
//remove the top element of the stack
void pop(stack* );
#endif
//stack.c
#include <stdio.h>
#include "stack.h"
#include <assert.h>
#include <stdlib.h>
//construct (initialize) an empty stack
stack* stack_init(void)
{
stack* s = (stack*)malloc(sizeof(stack));
assert(s);
s->myTop = -1;//stack is empty
return s;
}
//return 1 if stack is empty and 0 otherwise
int empty(stack *s)
{
assert(s);
if(0 > s->myTop)
return 1;
else
return 0;

}
//retrieve top element of the stack
stackEle top(stack* s)
{
assert(s);
if(0 > s->myTop)
{
printf("Error:stack is empty--no value can be reported\n");
exit(1);
}
return s->myArray[s->myTop];
}
//add an element at the top of the stack
void push(stack* s,stackEle val)
{
assert(s);
s->myTop++;
if(STACK_CAPACITY < s->myTop)//check if overflow
{
printf("Error:stack is full--can't add new value\n");
exit(1);
}
s->myArray[s->myTop] = val;
}
//remove the top element of the stack
void pop(stack* s)
{
assert(s);
if(0 > s->myTop)//check if underflow
{
printf("Error:stack is empty--can't remove a value\n");
exit(1);
}
printf("%d ",s->myArray[s->myTop--]);
}
//do base-10 to base-2 transformation by array-based stack
int main()
{
stack *mystack = stack_init();
int a = 255,b,base = 2;
do
{
b = a % base;
push(mystack,b);
a = a / base;
} while(a != 0);

while(!empty(mystack))
pop(mystack);


Ïà¹ØÎĵµ£º

LINUX C ʱ¼ä²Ù×÷

  1.ʱ¼ä±íʾ
    ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ­³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û.Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý:
#include <sys/time.h>
time_t time(time_t *tloc);
char *ctime(const time_t *clock);
    timeº¯Êý·µ»Ø´Ó1970Äê1ÔÂ1ÈÕ0 ......

c ÓïÑÔʵÏÖ24λbmpͼƬ¼ÓÔØ£¬¶Áд£¬·Å´óËõС

Ô­ÎÄÁ´½ÓµØÖ·£ºhttp://hi.baidu.com/erfolgreich/blog/item/ce94dbad02c0c3f7faed5010.html
c ÓïÑÔʵÏÖ24λbmpͼƬ¼ÓÔØ£¬¶Áд£¬·Å´óËõС
¿ÉÓà microsoft visual c++ 6.0 ½¨Á¢Win32 Console Application ¹¤³Ì£¬Ìí¼ÓÈçÏÂ.cpp
2010-04-30 10:24
·¢ÏֺöàÈËÍøÉϲéÕÒc ÓïÑÔ°æ±¾µÄbmpͼÏñ¶ÁÈ¡£¬±£´æ£¬·Å´ó£¬ËõС³ÌÐò£¬ºÜÄÑÕÒµ ......

C preprocessor

Ò»Ö±¾õµÃCÓïÑÔµÄÔ¤´¦Àí
Æ÷ÊǸöÃÀÃî¶øÉñÆæµÄ¹¤¾ß£¬ÒÔºó»áÂ½Ðø°Ñ×Ô¼ºÑ§µ½µÄ¹ØÓÚËüµÄÐÂ֪ʶ×ܽá³öÀ´¡£To be continued aways...
Ò»¡¢ #defineÌæ»»
£¨Pointer ON C
, Ch14.2.2£©
³ÌÐòÖÐÀ©Õ¹#define¶¨Òå·ûºÅºÍºêʱ£¬Éæ¼°Èçϼ¸¸ö²½Ö裺
(1) ÔÚµ÷Óúêʱ£¬Ê×ÏȶԲÎÊý½øÐмì²é£¬¿´¿´ÊÇ·ñ°üº¬ÁËÈκÎÓÉ#define ¶¨ÒåµÄ·ûºÅ£¬Èç¹ ......

C/C++µ¥Ôª²âÊÔÀíÂÛ¾«Òª£¨Ê®¶þ£¬Í꣩

4.2 ¶à½Ç¶È±£Ö¤²âÊÔЧ¹û
    ¶ÔÓÚ´úÂëÖÊÁ¿ÒªÇóºÜ¸ßµÄÏîÄ¿À´Ëµ£¬½öÓа׺и²¸ÇÊÇÔ¶Ô¶²»¹»µÄ¡£°×ºÐ¸²¸Ç²»ÄÜ·¢ÏÖ´úÂëȱʧ£¬°×ºÐ¸²¸Ç»ùÓÚÏÖÓдúÂ룬Èç¹û´úÂë²»´æÔÚ£¬µ±È»²»ÄÜ·¢ÏÖ¡£ÎªÁ˼ì²â´úÂëȱʧ£¬ÐèÒªÈ˹¤¶Ô²âÊÔÊý¾Ý½øÐмì²é¡£°×ºÐ¸²¸ÇÒ²²»ÄÜ·¢ÏÖÓÃÀýδ·´Ó³¹¦ÄÜ¡£Èç¹ûÉè¼ÆÓÃÀýʱ£¬²âÊÔÔ±²»Á˽â´úÂëµÄ¹¦ÄÜ£¬Í ......

[ת]C/C++ HOOK API£¨Ô­ÀíÉîÈëÆÊÎöÖ® LoadLibraryA£©

9Ô¶¼¿ì½áÊøÁË£¬Ö®Ç°Ò»Ö±Ã¦µ½Ð´×Ô¼ºµÄ¶«Î÷¼ÓÉÏÉϰࡣ»ù±¾Ã»ÓÐʱ¼äÑо¿Ï»ã±àºÍC C++·½ÃæµÄ¸ÐÐËȤµÄ¶«Î÷¡£ÔÙÔõô˵Â9Ô»¹ÊǵÃдһƪÈö£¬ÒÔºóÿÔÂÖÁÉÙһƪ°É¡£¸ø×Ô¼º¶¨ÁË£¬Ï£Íû´ó¼Ò¼à¶½¡£ºÙºÙ£¡
ÕâÆªÎÄÕ¾ÍÀ´Ì¸Ì¸Æ½³£ºÜ³£¼ûµÄHOOK¼¼Êõ£¬ÕâÀïÄØ¡£Ð´µÃ±È½Ï¼òµ¥£¬·½·¨ºÜ¶à¡£Ö»½²Ô­Àí£¡Ï£Íû´óÄñÃDZðÍÂÎÒ¿ÚË®¹þ - -¡£ºÃ£¡ÇÐÈëÕ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ