小编ash*_*bhy的帖子

无法使用 homebrew 在 mac 上安装特定版本的 go

我正在尝试安装 go lang 版本 1.12.7

brew install go@1.12.7
Run Code Online (Sandbox Code Playgroud)

但它的说法公式是错误的。任何帮助,将不胜感激。

homebrew go

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

运行我的C程序时在Linux中出现分段错误

我试图在Red Hat Linux中模拟cat命令.我运行程序时出现分段错误.

例如:

./a.out a > b
Run Code Online (Sandbox Code Playgroud)

a包含你好.我希望你好被复制b.

我的代码如下:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

int main(int argc,char *argv[])
{
    int f, fd, r;
    char buf[100];

    if (argc < 2)
    {
        printf("Error");
        return 0;
    }
    else
    {
        if (!strcmp(argv[2],">"))
        {
            f = open(argv[1],0,00777);

            if (f == -1)
                printf("no file");
            else
            {
                fd = creat(argv[3],00777);
                while( (r = read(f,buf,50)) > 0)
                    write(fd, buf, r);
            } …
Run Code Online (Sandbox Code Playgroud)

c linux simulation

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

试图模拟grep命令

我编译代码时出现分段错误.

如果有人可以帮助我,我的代码会很高兴我没有得到什么问题.

#include<stdio.h>
#include<string.h>

int main(int argc,char *argv[])
{
FILE *fp;
char fline[100];
char *newline;
int i,count=0,occ=0;

fp=fopen(argv[1],"r");

while(fgets(fline,100,fp)!=NULL)
{
count++;
    if(newline=strchr(fline,'\n'))
        *newline='\0';
    if(strstr(fline,argv[2])!=NULL)
    {
        printf("%s %d %s",argv[1],count,fline);
    occ++;  
    }


}

printf("\n Occurence= %d",occ);

return 1;
}
Run Code Online (Sandbox Code Playgroud)

c linux

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

如何将时间增加15分钟

MySql数据库中,我们有一个类型为time的列,我们需要在php代码中将时间增加十五分钟.

例如时间是09:45:00,应该是10:00:00

php mysql datetime

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

标签 统计

c ×2

linux ×2

datetime ×1

go ×1

homebrew ×1

mysql ×1

php ×1

simulation ×1