我尝试安装 pg gem。但它会产生以下错误。谁能帮我解决这个问题?
root@localhost:/home/rails/Project# gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pg-0.18.4/ext
/usr/bin/ruby2.3 -r ./siteconf20160908-9582-xu3pmx.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h... no …Run Code Online (Sandbox Code Playgroud) 我是C的新手.为了存储字符串文字,我看到了两种方式,如下所示
char s[]="Mohan";
char *ptr="Mohan";
Run Code Online (Sandbox Code Playgroud)
那么,这两者之间有什么区别.以及如何为这两个语句分配内存.
提前致谢...
在unix中打开系统调用
以下是开放系统调用的原型:
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
Run Code Online (Sandbox Code Playgroud)
pathname - >它用于提及文件的路径,如/home/mohan/a.txt
flags - >用于提示文件将以哪种模式打开,如Readonly,writeonly或readwrite.
模式 - >?
什么是模式的使用以及何时使用模式.有没有使用模式的例子.
提前致谢.
程序:
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
void main()
{
struct stat stbuf;
stat("alphabet",&stbuf);
printf("Access time = %d\n",stbuf.st_atime);
printf("Modification time = %d\n",stbuf.st_mtime);
printf("Change time = %d\n",stbuf.st_mtime);
}
Run Code Online (Sandbox Code Playgroud)
上面的程序给出了以下输出:
输出:
$ ./a.out
Access time = 1441619019
Modification time = 1441618853
Change time = 1441618853
$
Run Code Online (Sandbox Code Playgroud)
它以秒为单位打印日期.在C中,将时间打印为由stat函数返回的人类可读格式的方法是什么.返回类型stbuf.st_atime是__time_t.
提前致谢...
计划1:
#include<stdio.h>
void main()
{
printf("Hello\n");
}
Run Code Online (Sandbox Code Playgroud)
输出:
$strace ./a.out
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
.
.
.
.
write(1, "Hello\n", 6Hello
) = 6
exit_group(6) = ?
$
Run Code Online (Sandbox Code Playgroud)
计划2:
#include<stdio.h>
void main()
{
char buf[2];
setbuf(stdout,buf);
printf("Hello\n");
}
Run Code Online (Sandbox Code Playgroud)
输出:
$ strace ./a.out
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
.
.
.
. …Run Code Online (Sandbox Code Playgroud) 程序:
#include<stdio.h>
#include<string.h>
char *f_gets(char *s, int n, FILE *iop)
{
int c=0;
char *cs;
cs = s;
while (--n > 0 && (c = getc(iop)) != EOF)
{
if ((*cs++ = c) == '\n')
break;
}
*cs = '\0';
return (c == EOF && cs == s) ? NULL : s;
}
main(int argc, char *argv[])
{
FILE *fp1,*fp2;
char s2[100],s1[100];
if (argc <= 2 )
printf("2 argument needed \n");
else
if((fp1=fopen(argv[1],"r"))== NULL && (fp2=fopen(argv[2],"r"))==NULL)
printf("cat: can't open The …Run Code Online (Sandbox Code Playgroud) 我正在使用ubuntu 12.04。我试图在命令提示符下获取我的公共IP地址。但是,它仅显示本地ip。有什么办法可以从命令行获取公共IP。
我是红宝石的新手.当我尝试读取没有换行符的行时,我学习了chomp方法.此方法用于从字符串末尾删除\n.所以,我尝试了以下方案.
程序:
arr = Array.new;
while true
char = gets // Read line from input
if char == nil // If EOF reach then break
break
end
char.chomp // Try to remove \n at the end of string
arr << char // Append the line into array
end
p arr // print the array
Run Code Online (Sandbox Code Playgroud)
输出:
$ ruby Array.rb
abc
def
["abc\n", "def\n"]
$
Run Code Online (Sandbox Code Playgroud)
但它不会删除字符串末尾的换行符.但如果'!' 在chomp(char.chomp!)的末尾提供,它工作正常.那么"!"的需求是什么?以及为什么使用它?什么 !代表 ?
我不明白以下for循环的流程:它变成了一个无限循环.我使用的是ubuntu 12.04.我在这里做错了吗?
#include <stdio.h>
main()
{
int k,a[10];
for(k=0; k<=10; k++)
{
a[k]=1;
printf("k = %d\n",k);
}
}
Run Code Online (Sandbox Code Playgroud)
一旦k == 9,它会自动更改为1.我不知道它为什么会这样.我究竟做错了什么?
c ×6
linux ×5
unix ×5
ruby ×2
for-loop ×1
ip-address ×1
pg ×1
pointers ×1
rubygems ×1
strace ×1
system-calls ×1
ubuntu-12.04 ×1