小编Kel*_*lly的帖子

Windows BATCH脚本错误 - 执行(此时是意外的

我尝试运行一个简单的批处理脚本,如下所示.基本上我想访问给定目录中的每个子目录并运行gmake命令.

echo %USER_DEF_VAR%
cd %USER_DEF_VAR%\topLevelDir
for /D %G in ("%USER_DEF_VAR%\topLevelDir\*") do ( 
cd %G
gmake clean
gmake 
)
Run Code Online (Sandbox Code Playgroud)

如果我在命令行上运行此脚本,它可以正常工作.但是,当我把它放在一个.bat脚本中时,它会抛出一个错误说

做(此时出乎意料.

我试图尽可能删除空格,如此处所示 - 嵌套For循环批处理文件错误:此时出现意外

我仍然面临同样的问题.

batch-file

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

用C++中的%20替换字符串中的空格

#include <iostream>
#include <string>

void removeSpaces(std::string );

int main()
{
        std::string inputString;
        std::cout<<"Enter the string:"<<std::endl;
        std::cin>>inputString;

        removeSpaces(inputString);

        return 0;
}



void removeSpaces(std::string str)
{
        size_t position = 0;
        for ( position = str.find(" "); position != std::string::npos; position = str.find(" ",position) )
        {
                str.replace(position ,1, "%20");
        }

        std::cout<<str<<std::endl;
}
Run Code Online (Sandbox Code Playgroud)

我无法看到任何输出.例如

Enter Input String: a b c
Output = a
Run Code Online (Sandbox Code Playgroud)

怎么了?

c++ string

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

使用Perl比较两个目录

我是Perl的新手,请原谅我的无知,

这是我打算做的.

$ perl dirComp.pl dir1 dir2
Run Code Online (Sandbox Code Playgroud)

dir1和dir2是目录名称.

脚本dirComp.pl应该识别dir1和dir2中的内容是否相同.

我想出了一个算法

Store all the contents of dir1(recursively) in a list
Store all the contents of dir2 in another list
Compare the two list, if they are same - dir1 & dir2 are same else not.

my @files1 = readdir(DIR1h);
my @files2 = readdir(DIR2h);

    # Remove filename extensions for each list.

        foreach my $item (@files1) {
        my ( $fileName, $filePath, $fileExt ) = fileparse($item, qr/\.[^.]*/);
        $item = $fileName;
        }


        foreach my $item …
Run Code Online (Sandbox Code Playgroud)

perl

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

多个模块,一个类的单个实例 - Python

我有两个模块 misc.py 和 main.py,并且想在 main.py 中定义 misc.py 中存在的所有类。

下面是代码

#misc.py

class dummy:
    def __init__(self):
        pass
    def dummyPrint(self):
        print "Welcome to python"

#main.py

 import misc
 dummyObj = dummy()
 dummyObj.dummyPrint()
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?我没有看到任何输出,即欢迎使用 python

$python misc_main.py misc.py
Run Code Online (Sandbox Code Playgroud)

编辑:我添加了来自 misc import dummy 的语句,但出现以下错误

$python misc_main.py main.py

Traceback (most recent call last):
File "misc_main.py", line 5, in <module>
dummyObj =  dummmy()
NameError: name 'dummmy' is not defined
Run Code Online (Sandbox Code Playgroud)

python

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

失踪 ';' 在'类型'之前

#include <stdio.h>
#include <stdlib.h>

typedef struct student {
    int  rollNo;
    char studentName[25];
    struct student *next;
}node;

node *createList();
void printList(node *);


int main()
{
    node *head;
    head = createList();
    void printList(node *head);



    return 0;
}

node *createList()
{
    int idx,n;
    node *p,*head;
    printf("How many nodes do you want initially?\n");
    scanf("%d",&n); 

    for(idx=0;idx<n;++idx)
    {
        if(idx == 0)
        {
            head = (node*)malloc(sizeof(node));
            p = head;
        }
        else
        {
            p->next = (node*)malloc(sizeof(node));
            p = p->next;
        }
        printf("Enter the data to be stuffed inside the …
Run Code Online (Sandbox Code Playgroud)

c

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

查找二进制搜索树中的最小元素 - 进入无限循环

我使用递归方法来创建二进制搜索树.我的目标是找到树中的最低元素.以下是我的代码.

插入

node insert(node root, int value)
{
        if ( root == NULL )
        {
                return ((newNode(value)));
        }

        if ( root->info == value )
        {
                std::cout<<"Duplicate entry found!"<<std::endl;
                return root;
        }
        else if ( root->info > value )
        {
                root->lChild = insert(root->lChild,value);
        }
        else if ( root->info < value )
        {
                root->rChild = insert(root->rChild,value);
        }
        else 
                std::cout<<"Some error has occurred.Time to debug!"<<std::endl;

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

MinValue函数

int minValue(node curPtr)
{
        node temp = curPtr;
        while ( curPtr )
        {
                temp …
Run Code Online (Sandbox Code Playgroud)

c++ binary-search-tree

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

我在哪里可以找到在Vim中在光标下打开文件的插件

我指的是这个特殊的插件 http://vim.wikia.com/wiki/Open_file_under_cursor

我尝试在vim网站上搜索,但我无法找到它.谷歌搜索了很多,但没有运气.

谁能指出我正确的链接?

vim plugins

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

标签 统计

c++ ×2

batch-file ×1

binary-search-tree ×1

c ×1

perl ×1

plugins ×1

python ×1

string ×1

vim ×1