小编Hus*_*ada的帖子

getop()函数K&R book p 78

我正在学习K&R书.目前我正在阅读函数getop(),第78页.我理解代码,但我需要澄清两件事.

getop()的代码如下:

int getch(void);
void ungetch(int);

/* getop: get next character or numeric operand */
int getop(char s[])
{
    int i, c;
    while ((s[0] = c = getch()) == ' ' || c == '\t')
        ;
    s[1] = '\0';

    if (!isdigit(c) && c != '.')
        return c; /* not a number */

    i = 0;
    if (isdigit(c)) /* collect integer part */
        while (isdigit(s[++i] = c = getch()))
            ;
    if (c == '.') /* collect fraction part */
        while (isdigit(s[++i] …
Run Code Online (Sandbox Code Playgroud)

c kernighan-and-ritchie

5
推荐指数
1
解决办法
1140
查看次数

K&R书籍练习4-2

我正在学习K&R书.我目前在第4章.我正在阅读第71页的atof()函数.函数atof(s)将字符串转换为其双精度浮点等效值.

atof()的代码如下:
// atof:将string s转换为double

double atof2(char s[])
{
   double val, power;
   int i, sign;

   for (i = 0; isspace(s[i]); ++i) //skip white space
       ;
   sign = (s[i] == '-') ? -1: 1;
   if (s[i] == '-' || s[i] == '-')
       ++i;

   for (val = 0.0; isdigit(s[i]); i++)
       val = 10.0 * val + (s[i] - '0');

   if (s[i] == '.')
       ++i;
   for (power = 1.0; isdigit(s[i]); i++) {
       val = 10.0 * val + (s[i] - '0');
       power *= …
Run Code Online (Sandbox Code Playgroud)

c kernighan-and-ritchie

3
推荐指数
1
解决办法
146
查看次数

如何在Homestead和我的本地计算机之间创建共享文件夹

我是计算机科学专业的毕业生。我刚刚在一家使用Laravel的公司开始实习。我的第一个任务是安装Homestead。我做到了 我的第二个任务是在Homestead和我的本地计算机(我有一个Macbook Pro)之间创建一个共享文件夹。我快速浏览了Laravel文档,但没有找到与该主题直接相关的文章。有人可以帮助我解决这个问题吗?(如何在Homestead和本地计算机之间创建共享文件夹?)

php laravel homestead

2
推荐指数
1
解决办法
1961
查看次数

标签 统计

c ×2

kernighan-and-ritchie ×2

homestead ×1

laravel ×1

php ×1