简体   繁体   中英

How to write in C starting at a certain point in the buffer?

Simple question. I've been trying to find the answer before asking but i dont know if im wording the question right.

I want to write in C using write(int fd, char* buffer, size) .

char buffer[40];
//just assume the buffer has been read into.
write(fdout,buffer,40);

I want to write say starting at index 2 of the buffer so from buffer[2] to the end skipping the first 2 characters. To do this would I have to make another char* and concat the buffer excluding the first 2 characters?

您只需要一个指向缓冲区中正确位置的指针:

write(fdout, &buffer[2], 40-2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM