c°æ±¾Óëc++°æ±¾µÄ¶¯Ì¬Êý×é´úÂë
C°æ±¾£º
vim stash.h
#ifndef STASH_H
#define STASH_H
typedef struct STASHTag {
int size; /* Size of each space */
int quantity; /* Number of storage spaces */
int next; /* Next empty space */
/* Dynamically allocated array of bytes: */
unsigned char* storage;
} Stash;
void initialize(Stash* S, int Size);
void cleanup(Stash* S);
int add(Stash* S, void* element);
void* fetch(Stash* S, int index);
int count(Stash* S);
void inflate(Stash* S, int increase);
#endif //STASH_H
vim stash.c
/* Error testing macros: */
#include <assert.h>
/* Dynamic memory allocation functions: */
#include <stdlib.h>
#include <string.h> /* memcpy() */
#include <stdio.h>
#include "stash.h"
#define STEP 10
void initialize(Stash* S, int Size) {
S->size = Size;
S->quantity = 0;
S->storage = 0;
S->next = 0;
}
void cleanup(Stash* S) {
if(S->storage) {
puts("freeing storage");
free(S->storage);
}
}
int add(Stash* S, void* element) {
/* enough space left? */
if(S->next >= S->quantity)
inflate(S, STEP);
/* Copy element into storage,
starting at next empty space: */
memcpy(&(S->storage[S->next * S->size]),
element, S->size);
S->next++;
return(S->next - 1); /* Index number */
}
void* fetch(Stash* S, int index) {
if(index >= S->next || index < 0)
return 0; /* Not out of bounds? */
/* Produce pointer to desired element: */
// return &(S->storage[index * S->size]);
return (S->storage+index*S->size);
}
int count(Stash* S) {
/* Number of elements in stash */
return S->next;
}
void inflate(Stash* S, int increase) {
void* v =
realloc
Ïà¹ØÎĵµ£º
CÏÝÚåÓÚȱÏÝÕâ±¾Ê鵽ͼÊé¹Ý½èÁ˺ܾã¬Ò»Ö±¶¼Ã»ÓÐϸϸµÄ¿´£¬ÏÖÍêÕûµÄ¿´ÁËÖ®ºó°ÑÈÏÎªÖØÒªµÄ£¬Ò»°ãÈË¿ÉÄܺöÊÓµÄÎÊÌâ¸ø×öÁ˱ʼǣ¬Ï£ÍûÓÐËù°ïÖú
2010.02.25
¶þάÊý×é:
int calendar[12][31];
int * p;
int i;
calendar[4]µÄº¬Ò壺
calendar[4]ÊÇcalendarÊý×éµÄµÚ5¸öÔªËØ£¬ÊÇcalendarÊý×éÖÐ12¸öÓÐ×Å31¸öÕûÐÍÔªËØµÄÊý×éÖ®Ò» ......
1. Ê×ÏÈÒªÀí½â¼¸¸ö¸ÅÄ
Îļþ£º °´Ò»¶¨¹æÔò´æ´¢ÔÚ´ÅÅÌÉϵÄÊý¾Ý¼¯ºÏ¡£
ÎļþÃû£º ÄÜΨһ±êʶij¸ö´ÅÅÌÎļþµÄ×Ö·û´®¡£ÐÎʽ£º ÅÌ·û£º\ ·¾¶ \ ÎļþÃû.À©Õ¹Ãû
Îı¾Îļþ:£º Êý¾ÝÒÔÆäÊý×Ö×Ö·ûµÄASCIIÂëÐÎʽ¡¢Ò»¸ö×Ö½ÚÒ»¸ö×ֽڵش洢ÔÚ´ÅÅÌÉÏ¡£
¶þ½øÖÆÎļþ£ºÊý¾ÝÒÔ¶þ½øÖÆÐÎʽÔÚ´æ´¢ÔÚ´ÅÅÌÉÏ¡£
£¨Îı¾ÎļþºÍ¶ ......
char * c = "hello"; cÊǸö·ÖÅäÔÚ¶ÑÕ»ÖеÄÒ»¸ö±äÁ¿¡£ÀïÃæ×°µÄÊÇ×Ö·û´®helloµÄÊ×µØÖ·£¬¶øhelloÊdz£Á¿Çø¡£PEÎļþÔÚ±àÒëµÄʱºò¾ÍÈ·¶¨Á˵ġ£
char []c = "hello";
"hello"ÊÇ·ÅÔÚ¶ÑÕ»Öб£´æµÄ£¬¸úÉÏÃæµÄÄǸöÀý×Ó²»Í¬£¬ÓÉÓÚhelloÊǶÑÕ»ÖеÄËùÒÔÊÇ¿ÉÒÔÐ޸ĵġ£¶ø³£Á¿ÇøÀïµÄÊDz»¿ÉÒÔÐ޸ĵġ£ÒòΪPEµÄÄÚ´æÒ³ÊôÐÔÊÇÖ»¶ÁµÄ¡£µ±È»¿ÉÒÔ ......
ÔÚjavaÖе÷ÓÃ×Ô¼ºµÄc++´úÂëÊÇÒ»¼þ¼òµ¥µÄÊÂÇ飬ÒÔÏÂÀàΪÀý£º
class Prompt {
private native String getLine(String prompt);
public static void main(String args[]) {
Prompt p = new Prompt();
String input = p.getLine("Type a line: ");
&nbs ......
VC++ÖвÙ×÷XML£¨MFC¡¢SDK£©
2009Äê01ÔÂ07ÈÕ ÐÇÆÚÈý 22:33
XMLÔÚWin32³ÌÐò·½ÃæÓ¦¸ÃûÓÐÔÚWeb·½ÃæÓ¦Óõö࣬ºÜ¶à
Win32³ÌÐòÒ²Ö»ÊÇÓÃXMLÀ´´æ´æÅäÖÃÐÅÏ¢¶øÒÑ£¬¶øÇÒûÓÐ×ã¹»
µÄºÃ´¦µÄ»°»¹²»ÈçÓà ini¡£VC++Àï²Ù×÷XMLÓÐÁ½¸ö¿â¿ÉÒÔÓãº
MSXMLºÍXmlLite¡£MSXMLÓÖϸ·ÖÁËÁ½ÖÖ½Ó¿Ú£ºDOMºÍSAX2¡£XPû×Ô´øÓÐ XmlLite£¬Ö»×Ô´øÓÐ2.x¡¢3 ......