Redian新闻
>
Gone! manuscript review 转让 (cardiac fibroblast differentiatio
avatar
Gone! manuscript review 转让 (cardiac fibroblast differentiatio# Immigration - 落地生根
a*d
1
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 buf.
没懂是在考什么?哪位大牛能给点提示。谢谢
avatar
t*r
2
Topic: cardiac fibroblast reversible differentiation
一个不错的专业杂志。如有兴趣请尽快站内邮件联系。请附简历。
如有合适者我会推荐,但不保证能成功。
谢谢!
avatar
m*i
3
simple coding question. using static concept.

as

【在 a**d 的大作中提到】
: 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 buf.
: 没懂是在考什么?哪位大牛能给点提示。谢谢

avatar
G*d
4
Hi
I am interested. I am doing fibroblast and will send u cv tmr
Pls leave the chance for me

【在 t********r 的大作中提到】
: Topic: cardiac fibroblast reversible differentiation
: 一个不错的专业杂志。如有兴趣请尽快站内邮件联系。请附简历。
: 如有合适者我会推荐,但不保证能成功。
: 谢谢!

avatar
A*3
5
Where can find FB hardware design practical?
avatar
t*r
6
Please send me the following information:
your name, email address, institute, research interest, and selected
relevant publications
avatar
a*d
7
请问大牛能否给点详细提示。谢谢

【在 m**i 的大作中提到】
: simple coding question. using static concept.
:
: as

avatar
d*k
8
//欢迎拍砖,共同提高。
char* readLine(char* ret) {
vector store;
static char buf[SIZE];
static buf_size = 0;

while (true) {
if (buf_size == 0) {
buf_size = read(buf, SIZE);
}
int last = 0;
for (last = 0; last < buf_size && buf[last] != '\n'; ++last);
copy(buf, buf + last, back_inserter(store));
if (last < buf_size) {
buf_size = buf_size - (last + 1);
memmove(buf, buf + last + 1, buf_size)
break;
}
buf_size = 0;
}
char* ret = new char[store.size()];
copy(store.begin(), store.end(), ret);
return ret;
}
avatar
t*i
9
刚发现 让我们用的是 int read(char* buf, int len) 和char * readLine()是两个东
西。
read(buf, len)的返回值和len不一样,就可以block了。
int read(char* buf, int len) 主要计算每次读入len长有没有终止
avatar
o*8
10
似乎有bug:
假如SIZE=10,在第15个字符出现n. 第一行读出来返回没问题,但剩余的5个字符
memmove到前面还没推进store,就被第二次ReadLine开始的read冲掉了。
另外好像还有个off by 1 bug

【在 d*k 的大作中提到】
: //欢迎拍砖,共同提高。
: char* readLine(char* ret) {
: vector store;
: static char buf[SIZE];
: static buf_size = 0;
:
: while (true) {
: if (buf_size == 0) {
: buf_size = read(buf, SIZE);
: }

avatar
w*e
11
这道题里的block是什么意思?跟那道用read4096()实现readline()有什么区别?
谢谢

as

【在 a**d 的大作中提到】
: 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 buf.
: 没懂是在考什么?哪位大牛能给点提示。谢谢

avatar
n*e
12
请问什么是static concept?

【在 m**i 的大作中提到】
: simple coding question. using static concept.
:
: as

avatar
s*u
13
老题了吧,不过老要写错,尤其是那个read4写read的更恶心。
#define MAX_LEN 4096
int read(char* buf, int len);
char *readLine(){

static bool EOF = false;
char *str = NULL;
int i, size = 0;

static int currentPos = MAX_LEN;

static char* buffer = new char[MAX_LEN];

while(!EOF || currentPos != MAX_LEN ){

// buffer is not empty, handle buffer first
if(currentPos != MAX_LEN){

for(i = currentPos; i < MAX_LEN; i++)
if( buffer[i] == '\0' || buffer[i] == '\n' ){
i++;
break;
}

int oldsize = (str == NULL)? 0: strlen(str);

//resize the size of str;
size += i - currentPos;
str = (char*) realloc(str,sizeof(char)*(size + 1));

//copy the buffer into str;
memcpy(s + oldsize,buffer + currentPos,i - currentPos);
str[size] = '\0';
currentPos = i;

if( buffer[i-1] == '\0' || buffer[i-1] == '\n' )
return str;
}else{

int size = read( buf, MAX_LEN);
currentPos = 0;
if( size < MAX_LEN )
EOF = 1;
}
}

return str;
}
avatar
w*e
14
你的代码好像有问题。
如果read()没有读满max_size, eof已经为1了,这个时候buffer是没有填满的。在此之
前如果hit了一个‘n’。currentPos会记录'n‘后面的一个位置。
当第二次进入该函数的时候,你的while循环会从currentPos一直都到buffer的尾端,
而实际上,由于上次hit了eof,buffer是没有填满的。你的代码读入了一些多余的数据。

【在 s********u 的大作中提到】
: 老题了吧,不过老要写错,尤其是那个read4写read的更恶心。
: #define MAX_LEN 4096
: int read(char* buf, int len);
: char *readLine(){
:
: static bool EOF = false;
: char *str = NULL;
: int i, size = 0;
:
: static int currentPos = MAX_LEN;

avatar
d*k
15
I indeed forgot to add a ';'
But I don't think what you said is correct. In your case, notice the 'break'
which will prevent read() from being called.
What off by 1 are you talking about, btw? Please give me a case if possible.
thx

【在 o**8 的大作中提到】
: 似乎有bug:
: 假如SIZE=10,在第15个字符出现n. 第一行读出来返回没问题,但剩余的5个字符
: memmove到前面还没推进store,就被第二次ReadLine开始的read冲掉了。
: 另外好像还有个off by 1 bug

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。