小编aga*_*row的帖子

未定义的方法"cheffish"为nil:NilClass,供应厨师与流浪汉

我正在尝试使用Chef在Vagrant盒子中运行django-server,但是我已经被困在这几个小时并且在网上找不到任何东西.我的vagrantfile的相关位看起来像这样:(抱歉可怜的缩进)此外,该框运行centos7.

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apache2"
chef.add_recipe "apt"
chef.add_recipe "bluepill"
chef.add_recipe "build-essential"
chef.add_recipe "chef-sugar"
chef.add_recipe "chef_handler"
chef.add_recipe "cms-scanner"
chef.add_recipe "gunicorn"
chef.add_recipe "homebrew"
chef.add_recipe "install_from"
chef.add_recipe "iptables"
chef.add_recipe "logrotate"
chef.add_recipe "metachef"
chef.add_recipe "mysql"
chef.add_recipe "nginx"
chef.add_recipe "ohai"
chef.add_recipe "openssl"
chef.add_recipe "packagecloud"
chef.add_recipe "pacman"
chef.add_recipe "python"
chef.add_recipe "rbac"
chef.add_recipe "redis"
chef.add_recipe "runit"
chef.add_recipe "smf"
chef.add_recipe "windows"
chef.add_recipe "yum"
chef.add_recipe "yum-epel"
end
Run Code Online (Sandbox Code Playgroud)

我跑的时候会收到这个错误 vagrant provision

 C:\Users\garrowa\Desktop\cms-vagrant>vagrant provision
    ==> default: Running provisioner: chef_solo...
    ==> default: Detected Chef (latest) is already …
Run Code Online (Sandbox Code Playgroud)

chef-infra vagrant

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

使用scanf进行分段错误

noob问题:我正在尝试编写一个简单的菜单界面,但我不断收到分段错误,我无法弄清楚原因.

#include <stdlib.h>
#include <stdio.h>
int flush(); int add(char *name, char *password, char *type); int delete(char *name);
int edit(char *name, char *password, char *type, char *newName, char *newPassword, char            *newType);
int verify(char *name, char *password);



int menu(){
    int input;
    char *name, *password, *type, *newName, *newPassword, *newType;
    printf("MAIN MENU \n ============\n");
    printf("1. ADD\n");
    printf("2. DELETE\n");
    printf("3. EDIT\n");
    printf("4. VERIFY\n");
    printf("5. Exit\n");
    printf("Selection:");
    scanf("%d", &input);
    flush();
    switch (input){

    case 1:
        printf("%s\n", "Enter Name:");
        scanf("%s", name);
        flush();
        printf("%s\n", "enter password" );
        scanf("%s", password); …
Run Code Online (Sandbox Code Playgroud)

c segmentation-fault

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

重载运算符的返回值

如果这是一个非常基本的问题,我很抱歉,我对C++很陌生.我正在尝试为它定义自己的向量类和迭代器.但是,每当我重载操作符时,返回的值始终是一个地址.

例如,以下代码0x7fb6dbc000e0 0x7fb6dbc000e0在我想要打印时打印1 0

由于我一直在搞乱语法一段时间,一些运算符看起来有点不同,这只是为了让你看到我尝试过的一些东西.

test.cc

#include <iostream>
#include "TwoWayVector.cc"
int main(){
    TwoWayVector<int> numbers;
    numbers.push_back(3);
    numbers.push_back(2);
        TwoWayVectorIterator<int>* beginning = numbers.begin();
    TwoWayVectorIterator<int>* beginning2 = numbers.begin();
    cout << beginning==beginning2;
    cout << beginning != beginning2;
    cout << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)

TwoWayVector.cc

using namespace std;
#include "TwoWayVectorIterator.cc"
template <class T> class TwoWayVector{
public:

T* data;
int capacity;
int nextFree;

TwoWayVector(){
    capacity = 10;
    nextFree = 0;
    data = new T[capacity];
}

~TwoWayVector(){
    delete data;
}

T& operator[](const int index){
    if( …
Run Code Online (Sandbox Code Playgroud)

c++ templates pointers iterator reference

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

为什么输出字符串显示我从未写过的数据?

我正在编写一个程序,通过向每个字符添加10来加密文件.不知何故,一部分程序工作目录正在打印到文件中,我不明白为什么.

#include <stdio.h>
    int main(void){
        FILE *fp;
        fp=fopen("tester.csv","r+");
        Encrypt(fp);      
        fclose(fp);
    }

    int Encrypt(FILE *fp){
        int offset=10;
        Shift(fp, offset);
    }
    int Decrypt(FILE *fp){
        int offset= -10;
        Shift(fp, offset);
    }
    int Shift(FILE *fp, int offset){
        char line[50],tmp[50], character;
        long position;
        int i;
        position = ftell(fp);
        while(fgets(line,50,fp) != NULL){
            for(i=0;i<50;i++){
                character = line[i];
                character = (offset+character)%256;
                tmp[i] = character; 
                if(character=='\n' || character == 0){break;}                
            }
            fseek(fp,position,SEEK_SET);
            fputs(tmp,fp);
            position = ftell(fp);
            fseek(stdin,0,SEEK_END);
        }
      }
Run Code Online (Sandbox Code Playgroud)

该文件最初读取

this, is, a, test
i, hope, it, works!
Run Code Online (Sandbox Code Playgroud)

程序运行后: …

c output

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