j******n 发帖数: 108 | 1 很简单的一个问题,把 byte[] 转换成相应的 int[]
我写了一个循环,每次转换 4byte
因为需要转换的数量可能比较大,有几十万的int
我测了一下时间,还是不大能满足我的要求
请问,还有没有比较优化的方法么?比如类似 c 里面的 memcp
4byte 到 int 的转换如下:
int x = ((buf[start] & 0xFF) << 24)
| ((buf[start+1] & 0xFF) << 16)
| ((buf[start+2] & 0xFF) << 8)
| (buf[start+3] & 0xFF);
还是说,大概只能达到这个水平,很难再优化了?
非常感谢! |
|
k****f 发帖数: 3794 | 2 FILE*fp=fopen("youdata","r");
char buf[1000];
int first,second;
char third[10],fourth[10];
double fifth;
while(fgets(buf,sizeof(buf),fp)){
char*p=strtok(buf,"|");
if(p==NULL)break;
first=atoi(p);
p=strtok(NULL,"|");
second=atoi(p);
p=strtok(NULL,"|");
strcpy(third,p);
p=strtok(NULL,"|");
strcpy(fourth,p);
p=strtok(NULL,"|");
fifth=atof(p);
}
fclose(fp);
how
.
me |
|
X****r 发帖数: 3557 | 3 #include
#include
int main() {
int fd[2];
pipe(fd);
if (fork()) {
close(1);
dup2(fd[1], 1);
execlp("ssh", "ssh", "serv2", "ls");
} else {
int len;
char buf[256];
while ((len = read(fd[0], buf, 256)) >= 0) {
/* Process piece of output from buf[0] to buf[len-1]. */
}
wait(0);
}
}
ls'. |
|
t**********s 发帖数: 930 | 4 只找到了一个 catalina.properties:
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... 阅读全帖 |
|
w****a 发帖数: 155 | 5 我在写一个system call 的程序, 主要是用chdir实现改变当前目录,程序如下:
#include
#include
using namespace std;
int main()
{
char* path ="/home/ugrad1/arcbelly";
char* buf ;
buf = new char[256];
chdir(path);
getcwd(buf,256);
cout << buf << endl;
return 0;
}
执行完这个程序后,当前目录应该变到 /home/ugrad1/arcbelly
但是输出结果确是:
/home/ugrad1/arcbelly
The "temp" directory is my original one, so this means that this program
doesn't change the current directory. I think the "chdir" might not work.
请帮我看看是 |
|
r*t 发帖数: 34 | 6 【 以下文字转载自 Java 讨论区 】
【 原文由 rgt 所发表 】
偶在java中嵌套xml,程序如下:
StringBuffer buf = new StringBuffer();
buf.append("");
buf.append("\n
trylog.xsl\" ?>");
pw.println(buf.toString());
运行结果报如下错误:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet.
XML document must have a top level element. Error processing resource
请问如何解决? |
|
w*******y 发帖数: 60932 | 7 Link:
http://www.jetblue.com/deals/pop-up/?source=tznf
The sale ends 11:59 p.m. ET tonight. These fares are valid through Dec. 15,
however Nov. 23-30 is blacked out.
JetBlue flights feature leather seating, unlimited snacks and 36 channels of
free DirecTV. Plus, the first checked bag is free on all JetBlue flights.
From Aguadilla, PR (BQN)
$69* to New York City (JFK)
From Austin, TX (AUS)
$69* to Orlando, FL (MCO)
$69* to Fort Lauderdale, FL (FLL)
$84* to Long Beach, CA (LGB)
$89* to San Francis... 阅读全帖 |
|
x*******7 发帖数: 223 | 8 不知道发过没,在其他地方看到的。
Implement a function
char* readLine();
which returns single lines from a buffer. To read the buffer, you can makes
use of a function
int read(char* buf, int len)
which fills buf with upto len chars and returns the actual number of chars
filled in. Function readLine can be called as many times as desired. If
there is no valid data or newline terminated string available, it must block
. In order to block, it can use read function which in turn will block when
it doesn't have anyth... 阅读全帖 |
|
k***t 发帖数: 276 | 9 谁写了?或有没有好一些的online的参考答案?
用于对照检查自己写的是否全面。谢谢。
发信人: xicheng17 (super), 信区: JobHunting
标 题: fb面试题【转】
发信站: BBS 未名空间站 (Wed Nov 9 20:42:44 2011, 美东)
不知道发过没,在其他地方看到的。
Implement a function
char* readLine();
which returns single lines from a buffer. To read the buffer, you can makes
use of a function
int read(char* buf, int len)
which fills buf with upto len chars and returns the actual number of chars
filled in. Function readLine can be called as many times as desired. If
there is no valid data or newl... 阅读全帖 |
|
k***t 发帖数: 276 | 10 自己顶一下,大拿们都不屑于写这个readLine()吗?
这道readLine()的题到底想考什么?
StackOverflow上的一个comment说要考security和memleak。
Implement a function
char* readLine();
which returns single lines from a buffer. To read the buffer, you can makes
use of a function
int read(char* buf, int len)
which fills buf with upto len chars and returns the actual number of chars
filled in. Function readLine can be called as many times as desired. If
there is no valid data or newline terminated string available, it must block
. In order to bloc... 阅读全帖 |
|
h*****g 发帖数: 312 | 11 Implement a function
char* readLine();
which returns single lines from a buffer. To read the buffer, you can makes
use of a function
int read(char* buf, int len)
which fills buf with upto len chars and returns the actual number of chars
filled in. Function readLine can be called as many times as desired. If
there is no valid data or newline terminated string available, it must block
. In order to block, it can use read function which in turn will block when
it doesn't have anything to fill the b... 阅读全帖 |
|
c*****n 发帖数: 96 | 12 char* readLine(){
static char[BUFSIZE] buf;
static char* ptr = buf;
static int bufSize = 0;
int outputSize = 0;
char *output = NULL;
while (1){
int pos = getNewLinePos(ptr, bufSize);
if (pos > 0){
// found new line char in the buffer
output = realloc(output, outputSize+pos+1); // one extra char for '
\0'
// TODO: check realloc return value
memcpy (output + outputSize, ptr, pos);
output[outputSize + pos] = '\0';
... 阅读全帖 |
|
h*****g 发帖数: 312 | 13 多谢你的解答 觉得 //1 处的outputSize 应该时刻更新吧?
char* readLine(){
static char[BUFSIZE] buf;
static char* ptr = buf;
static int bufSize = 0;
int outputSize = 0;
char *output = NULL;
while (1){
int pos = getNewLinePos(ptr, bufSize);
if (pos > 0){
// found new line char in the buffer
output = realloc(output, outputSize+pos+1); // one extra char for '
\0'
// TODO: check realloc return value
memcpy (output + outputSize, ptr, pos);
outpu... 阅读全帖 |
|
l******s 发帖数: 13 | 14 考虑下面的代码,在Linux上运行:
// soc is a socket
if ( read(soc, buf, sizeof(buf)) > 0 )
{
snprintf(cmd, sizeof(cmd), "rm -f "%s"", buf);
system(cmd);
}
你会如何写script 检查证明这个漏洞存在,并没有任何破坏原有系统, 在这样一种方
式下,最终用户不会认为这是 false alarm? |
|
d*k 发帖数: 207 | 15 沒關係,樓主繼續加油啊,我連面試機會都木有。
int Read(int size, char* buffer) {
char buf[4];
int ret = 0;
while (ret < size) {
int sz = Read4(buf);
if (sz == 0) {
break;
}
int cp_size = min(sz, size - ret);
memcpy(buffer + ret, buf, cp_size);
ret += cp_size;
}
return ret;
} |
|
a**d 发帖数: 85 | 16 Implement a function char* readLine(); which returns single lines from a
buffer. To read the buffer, you can makes use of a function int read(char*
buf, int len) which fills buf with upto len chars and returns the actual
number of chars filled in. Function readLine can be called as many times as
desired. If there is no valid data or newline terminated string available,
it must block. In order to block, it can use read function which in turn
will block when it doesn't have anything to fill the bu... 阅读全帖 |
|
t******i 发帖数: 483 | 17 刚发现 让我们用的是 int read(char* buf, int len) 和char * readLine()是两个东
西。
read(buf, len)的返回值和len不一样,就可以block了。
int read(char* buf, int len) 主要计算每次读入len长有没有终止 |
|
q********c 发帖数: 1774 | 18 这道题挺有意思,不难但是要考虑几种情况, 试了一下:
int Read(char* buf, int n)
{
int total = 0;
while(true) {
total += Read4096(buf);
if(total == n || total < 4096) { break; }
if(total > n) {
total = n; buf += total;
break;
}
}
return total;
} |
|
q********c 发帖数: 1774 | 19 这道题挺有意思,不难但是要考虑几种情况, 试了一下:
int Read(char* buf, int n)
{
int total = 0;
while(true) {
total += Read4096(buf);
if(total == n || total < 4096) { break; }
if(total > n) {
total = n; buf += total;
break;
}
}
return total;
} |
|
s******7 发帖数: 1758 | 20 贴个java的
就是把read4多读出来的存起来, 下次先读这段剩余的,refactor了一下,看起来短点
,要是面试直接上多次引用,我第一次碰到半个小时肯定搞不定
private List left;
public int read(char[] buf, int n) {
if(left==null) left = new ArrayList();
int ptr = Math.min(n,left.size());
for(int i=0;i
left.subList(0,ptr).clear();
if(n
else{
while(ptr < n){
char[] b4 = new char[4];
int r = read4(b4);
... 阅读全帖 |
|
|
xt 发帖数: 17532 | 22 我搞到了一个小程序:
#include
#include
#include
#include
#include
int main( int argc, char** argv)
{
char buf[80] = {0};
int myfile;
pid_t pid;
struct psinfo psi;
if ( argc<2 ){
printf("Usage: %s PID\n", argv[0]);
return 1;
}
pid=atoi(argv[1]);
sprintf( buf, "/proc/%d/psinfo", pid);
myfile = open( buf, O_RDONLY );
if (myfile < 0)
perror( "open" );
if ( read( myfile, & psi, sizeof(psi) ) < 0 )
perror( "read" );
close( myfile );
printf( "%s |
|
g**********y 发帖数: 14569 | 23 Steve Johnson (Buf - WR) AddWaivers ($39)虚竹子(bison)
Lee Evans (Buf - WR) AddWaivers ($13)戒烟客(gloomyturkey)
Jon Kitna (Dal - QB) AddWaivers ($9)扫地僧(dango)
Jonathan Stewart (Car - RB) AddWaivers ($9)段誉(datang)
New England (NE - DEF) AddWaivers ($7)虚竹子(bison)
Owen Daniels (Hou - TE) AddWaivers ($6)张三丰 (berniefu)
Blair White (Ind - WR) AddWaivers ($5)扫地僧(dango)
Dan Carpenter (Mia - K) AddWaivers ($4)戒烟客(gloomyturkey)
Darren Sproles (SD - RB) AddWaivers ($3)杨逍(gochiefs)
Todd Heap (B... 阅读全帖 |
|
g**********y 发帖数: 14569 | 24 在所有的胜场里,假设你赢了X分,我们从低到高去掉不必要的player, 剩下的就是你需要感谢的骨干, 以下是你需要感谢的次数(截至15周)。
Peyton Manning(Ind) = 7
Pittsburgh(Pit) = 6
Frank Gore(SF) = 5
DeSean Jackson(Phi) = 5
LaDainian Tomlinson(NYJ) = 4
Vernon Davis(SF) = 3
Rob Bironas(Ten) = 3
Malcom Floyd(SD) = 3
Johnny Knox(Chi) = 2
Ryan Torain(Was) = 1
Matt Cassel(KC) = 1
Michael Crabtree(SF) = 1
Mike Williams(Sea) = 1
Shonn Greene(NYJ) = 1
Nate Kaeding(SD) = 1
Ben Obomanu(Sea) = 1
Louis Murphy(Oak) = 1
Chris Johnson(Ten) = 9
Rashard Mende... 阅读全帖 |
|
P*******e 发帖数: 39399 | 25 NFL 2012 Survivor (Win at Week 8)
baal: IND, CHI, STL, CAR, BUF, OAK, NYJ, JAC
bonus guess from Week 9: ARI
runner up:
pplulu: CLE, JAC, STL, TEN, NYJ, OAK, SEA, (TB)
寻找本轮比赛的输家
1. 选过的球队不可再选
2. 每轮截止日期为每轮第一场比赛开赛时刻 不选择者视为自动弃权
(截止日期之前允许修改 但是之后修改一律取消资格)
3. 如果选中球队本轮平局 可以继续参与后续比赛 两次平局淘汰 最后比较算半场
Week 8 survival rate:1/2
Week 7 survival rate: 2/2
Week 6 survival rate: 2/3
Week 5 survival rate: 3/3
Week 4 survival rate: 3/3
Week 3 survival rate: 3/15
week 2 survival rate: 15/25
week 1 survival rate: 21... 阅读全帖 |
|
|
T***u 发帖数: 1468 | 27 BUF有两个低位一轮
假如DEN签下表弟,可以把自己的高位一轮换BUF的两个低位一轮,BUF选QB |
|
c*******n 发帖数: 59 | 28 今年由于冬奥会原因,加上本身喜欢滑冰,开始喜欢上冰球。
本人关注了ott<->pit, Van<->lak, Bos<->Buf, Col<->sanj.
目前pit和van已经过关。
对于ott<->pit来说,个人觉得ott更像一个团队在比赛,而pit就是球星战术。 Crosby
确实很牛,也难怪加拿大人那么喜欢他。每次裁判开球的时候基本上都是他抢到,另外
个人技术,意识确实高人一筹。再加上超牛的markin,staal等猛将,挺进第二轮也是
实至名归。不过我还是觉得pit的守门员不行,毛毛糙曹的,比起loungo差远了
至于下一个对手,多半是was,个人觉得pit会赢,然后如果buf过关的话还有点悬念。
不过buf多半会被bos搞死的,这样的话pit会连续第三年赢得东部冠军。
至于西部,如果CHI被干掉的话,我看好van会赢的西部冠军
最后van会赢的Stanley Cup |
|
C*******g 发帖数: 9288 | 29 crosby就是足球里的巴西的来昂那多。
今年由于冬奥会原因,加上本身喜欢滑冰,开始喜欢上冰球。
本人关注了ott<->pit, Van<->lak, Bos<->Buf, Col<->sanj.
目前pit和van已经过关。
对于ott<->pit来说,个人觉得ott更像一个团队在比赛,而pit就是球星战术。 Crosby
确实很牛,也难怪加拿大人那么喜欢他。每次裁判开球的时候基本上都是他抢到,另外
个人技术,意识确实高人一筹。再加上超牛的markin,staal等猛将,挺进第二轮也是
实至名归。不过我还是觉得pit的守门员不行,毛毛糙曹的,比起loungo差远了
至于下一个对手,多半是was,个人觉得pit会赢,然后如果buf过关的话还有点悬念。
不过buf多半会被bos搞死的,这样的话pit会连续第三年赢得东部冠军。
至于西部,如果CHI被干掉的话,我看好van会赢的西部冠军
最后van会赢的Stanley Cup |
|
g*********6 发帖数: 1149 | 30 我用itasoftware随便搜了下,3月下旬ORD-BUF往返机票只有137刀,哪有楼主说的400+
?请楼主再仔细看看吧。
下面是我搜到的结果:
Chicago (ORD) to Buffalo (BUF) - Wed, Mar 21
Continental 6015 Dep: 7:27AM Arr: 9:57AM 1h 30m Embraer ERJ-
145 Coach (L)
OPERATED BY UNITED EXPRESS/EXPRESSJET AIRLINES
Buffalo (BUF) to Chicago (ORD) - Sat, Mar 24
Continental 589 Dep: 8:05AM Arr: 8:56AM 1h 51m Boeing 757
Coach (L)
OPERATED BY UNITED
Cost per passenger (including taxes & ... 阅读全帖 |
|
m*****0 发帖数: 390 | 31 Hi, I have a flight from SFO - DTW - BUF 11:00PM Dec 22, and the connection
flight is 10 AM, Dec 23.
I am wondering may I standby a morning flight with the same route SFO-DTW-
BUF 9:00 AM Dec 22, and connection is 16:00 PM Dec 22 ?
I checked the delta's policy, Same Day Stand by is possible. however, my
case is kinda of special. for SFO-DTW, should be no problem if seat is
available. however, the second part from DTW-BUF, the original is on Dec 23,
the one I am going to standby is one day earl... 阅读全帖 |
|
w********1 发帖数: 3492 | 32 Mon, 23 Jul 2012 21:22:21 PDT
In line with a fresh report from KGI Securities analyst Ming-Chi Kuo
claiming that Apple will be updating the iPod touch later this year with an
"all-new" design using the same in-cell touch display technology rumored to
be used in the next iPhone, Japanese blog Macotakara reports that Apple will
also be moving the iPod touch to a 4-inch display from the current 3.5-inch
display. Apple is otherwise said to be basing the iPod touch's internals
on the iPhone 4S, alth... 阅读全帖 |
|
p*******p 发帖数: 13670 | 33 HttpWebRequest request=(HttpWebRequest)WebRequest.Create(str_url);
HttpWebResponse response=(HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
int count = resStream.Read(buf, 0, buf.Length);
str_content=Encoding.Default.GetString(buf, 0,count);
得到了string之后发现里面的内容和我直接去那个网址,看source不一样,
好像是有一些script在里面,所以用ie打开的话会像server request一些data, 然后显示
出来, 但是用c#
得到的就不会去执行那些script,请问我怎么才能得到那些运行过之后,显示在IE里面的so
urce呢? |
|
Z****e 发帖数: 2999 | 34 try ByteBuffer:
ByteBuffer buf = ByteBuffer.wrap(byteArray);
buf.order(endianess); //set endianess
IntBuffer intBuf = buf.asIntBuffer(); //check for null
int[] intArray = intBuf.array();
的转换如下: |
|
E*V 发帖数: 17544 | 35 readlink(2) - Linux man page
Name
readlink - read value of a symbolic link
Synopsis
#include
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
Description
readlink() places the contents of the symbolic link path in the buffer buf,
which has size bufsiz. readlink() does not append a null byte to buf. It wil
l truncate the contents (to a length of bufsiz characters), in case the buff
er is too small to hold all of the contents.
Return Value
The call returns the count of char |
|
xt 发帖数: 17532 | 36 用我修改过的code,编译好后,到另一个路径做个softlink,
用softlink执行这个程序。
pid_t pid = getpid();
char buf[40]={0};
sprintf( buf,"/proc/%d/exe", pid);
size=readlink(buf, path, 90);
sleep(120);
你得到的结果会是你的a.out的真实路径
趁这个程序睡觉的时候,你到/proc/pid里面来个ls,
会发现那个exe指向你的soft link.如果你用shell
的readlink得到的也是softlink地址。
这个至少是在我的RHEL5上是这样 |
|
m***a 发帖数: 4 | 37 hey, thanks for pointing out that.
but anyone can explain this:
#include
class A
{
public:
static int i;
unsigned char * buf;
int j;
A(){i++; j = i; buf = new unsigned char[4*4096];cout<<"Construction:"<
endl;};
~A(){ delete [] buf;cout<<"Deconstruction:"<
};
int A::i;
main()
{
A a;
A aaa;
aaa = a;
A aaaa = a;
}
the output is
Construction:1
Construction:2
Deconstruction:1
Deconstruction:1
Deconstruction:1
Quite surpring! Why not prompt 'segmentation |
|
b***y 发帖数: 2799 | 38 ☆─────────────────────────────────────☆
leizj (lilith) 于 (Fri Sep 9 09:08:34 2005) 提到:
I have seen the following very simple C function
static int FindStartCode (unsigned char *Buf, int zeros_in_startcode)
{
int info;
int i;
info = 1;
for (i = 0; i < zeros_in_startcode; i++)
if(Buf[i] != 0)
info = 0;
if(Buf[i] != 1)
info = 0;
return info;
}
I am interested in this for loop
...........
for (i = 0; i < zeros_in_startcode; i++)
|
|
b********f 发帖数: 3 | 39 GCC编译无错,运行提示
"SEGMENTATION FAULT(CORE DUMPED)"
#include
int main()
{
char *buf;
unsigned int vel_h = 0x01;
unsigned int vel_l = 0xB159;
unsigned int temp = 0x01FD;
unsigned int pres = 0x004C;
unsigned int cal1 = 0x3340;
unsigned int cal2 = 0x1030;
unsigned int range = 0x01;
sprintf(buf,"%02X,%04X,%04X,%04X,%04X,%04X,%02X",vel_h,vel_l,temp,pres,
cal1,cal2,range);
printf("%s\r\n",buf);
return 0;
} |
|
c******g 发帖数: 63 | 40 一个比较大的仿真程序(NS-2,很多做网络的人应该都用过)里面,想把数据输出到文
件。在C++源码某个相关类里加了个ofstream类的成员函数ofs,开始仿真的入口点初始
化(也就是以ios::trunc打开相应文件),在此后的代码中输出时,在ofs << buf外头
加个if (即 if (ofs << buf) {...})也没有问题,但是输出的文件一直是空的(用
cout则可以确定buf里是有内容的),感觉很诡异。
于是,在输出前检验了ofs.is_open()、ofs.good()和ofs.bad(),发现值为true,
false, true。试了ofs.clear(),发现没用,就改用每次输出前重新用ios::app方式打
开一次这个文件(文件名是记在另一个成员变量outFileName中的),居然就work了,
但是这样会让程序速度大大减慢。于是另加了一句判断 if (!ofs.is_open() || !ofs.
good()) 才重新打开这个文件。这样速度提升了,内容也都写进去了。。。但是这还没
完。。。
改了一些其他的仿真参数仿真,又不行了(这诡异到居然是scen... 阅读全帖 |
|
xt 发帖数: 17532 | 41 是这样,
...
char fullpath[200];
pid_t pid=getpid();
char buf[40] = {0};
sprintf(buf,"%s%d%s","/proc/",pid,"/cwd");
length = readlink(buf, fullpath, sizeof(fullpath));
我检查了一下,发现length=0, 而且errno=0,
我在程序退出前sleep(120)然后查那个路径,发现
...
cwd ->
但是如果我进入"cwd"可以发现确实是进入了可执行文件那个子目录
怎么样能够得到cwd所指的路径? |
|
w*******y 发帖数: 60932 | 42 Link:
http://www.jetblue.com/deals/you-above-all/?source=EM101810_main&ed_rid=S31FOE1-Z8VBV-4C0YBT-5ZJBHU-CWUB4-v1&ed_mid=165417
From Austin, TX (AUS)
$79* to Fort Lauderdale, FL (FLL)$79* to Orlando, FL (MCO)$94* to Long Beach
, CA (LGB)$99* to San Francisco, CA (SFO)$129* to Boston, MA (BOS)$139* to
New York City (JFK)From Baltimore, MD (BWI)
$39* to Boston, MA (BOS)From Boston, MA (BOS)
$39* to Pittsburgh, PA (PIT)$39* to Baltimore, MD (BWI)$39* to New York City
(JFK)$39* to Buffalo, NY (BUF)... 阅读全帖 |
|
j*******n 发帖数: 461 | 43 车上有几个比较大的划伤,其中有一个能看到一些金属。问了body shop的人,说最少
得700,很可能上千。于是打算自己修。
看了看youtube,买了一些工具:Automative Primer, Basecoat+Midcoat color (same
as my car's color), Clearcoat, Ultra Buffing system (I think it is kind of
compound), Acrylic Lacquer Thinner, Sand paper package(400, 600 and 1000).
打算买一个buffing pad for drill. 请问还需要别的工具吗?
我看youtube上有人用sand paper,有人不用。还有人用湿的sand paper.有经验的朋友
能不能说说修的顺序?
多谢多谢! |
|
s********y 发帖数: 1670 | 44 请问 以下航段行李托运 有额外费用吗?
在cheapoair上预定回国机票
第一段BUF到JFK,是Jetblue
第二段JFK到PEK,是国航
我的行李在BUF托运后,需要在JFK取出来么?还是直接到北京
如果我是两个50磅的行李,需要给第一段的JetBlue 支付行李费用吗?
如果第一段是US airway,或者CO,会一样吗?
谢谢 |
|
b**********r 发帖数: 46 | 45
test3写错了。
正确版本
#include
int main()
{
char *p;
char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};
p = &(buf+1)[5];
printf("%d \n", *p);
} |
|
h****8 发帖数: 599 | 46 是不是因为 Mem* b = new(buf) Mem;调用的是class Mem中的被重载的new
如果换成 Mem* b = ::new(buf) Mem;试试看呢 |
|