给函数赋值?这是肿不回事?
- C/C++ code
void LowpanUdpAgent::sendmsg(int nbytes, AppData* data, const char* flags){ Packet *p; int n; assert (size_ > 0); n = nbytes / size_; if (nbytes == -1) { printf("Error: sendmsg() for Lowpan UDP should not be -1\n"); return; } // If they are sending data, then it must fit within a single packet. if (data && nbytes > size_) { printf("Error: data greater than maximum lowpan UDP packet size\n"); return; } double local_time = Scheduler::instance().clock(); while (n-- > 0) { p = allocpkt(); hdr_cmn::access(p)->size() = size_; hdr_rtp* rh = hdr_rtp::access(p); rh->flags() = 0; rh->seqno() = ++seqno_; hdr_cmn::access(p)->timestamp() = (u_int32_t)(SAMPLERATE*local_time); // add "beginning of talkspurt" labels (tcl/ex/test-rcvr.tcl) if (flags && (0 ==strcmp(flags, "NEW_BURST"))) rh->flags() |= RTP_M; p->setdata(data); target_->recv(p); } n = nbytes % size_; if (n > 0) { p = allocpkt(); hdr_cmn::access(p)->size() = n; //这里 hdr_rtp* rh = hdr_rtp::access(p); rh->flags() = 0; //这里 rh->seqno() = ++seqno_; hdr_cmn::access(p)->timestamp() = (u_int32_t)(SAMPLERATE*local_time); // add "beginning of talkspurt" labels (tcl/ex/test-rcvr.tcl) if (flags && (0 == strcmp(flags, "NEW_BURST"))) rh->flags() |= RTP_M; p->setdata(data); target_->recv(p); } idle();}hdr_cmn::access(p)->size() = n; //这里
hdr_rtp* rh = hdr_rtp::access(p);
rh->flags() = 0; //这里
怎么能给函数赋值?
[解决办法]
是给函数的返回值赋值。
[解决办法]
如果返回的是个变量的引用,是完全可以这样做的!
只要函数的调用返回值是个左值就能够赋值的
[解决办法]
*strrchr( szPath, '\\' ) = '\0';
相信很多人都这么干过吧