小编cae*_*sar的帖子

登录shell和交互式shell之间有什么区别?

什么是login shellinteractive shell,什么是.bash_profile.bashrc

bash shell interactive-shell

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

Git日志输出在特定的修订版本范围内

这是我的问题.如何获取特定路径的2个修订号之间的所有日志消息?让我通过例子解释.

我试着用这一行写它:

git -dir=/home/Desktop/GIT_REFERENCE_REPOSITORIES/manager.git log  10000...15000
Run Code Online (Sandbox Code Playgroud)

我假设它给了我与manager.git相关的10000到15000个修订版的日志消息.但事实并非如此.有人帮我吗?

git git-log

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

使用svn diff命令

由于我是SVN的新手,我的问题有点简单,但在问这里之前,我确实看过官方教程,但那里的解释并没有给我任何线索.所以我希望我能找到适合我的人.提前致谢!

这是我的问题:如何使用svn diff我的存储库中的文件和我目前正在处理的文件之间的差异?我的意思是,结帐后更改但尚未添加和提交的文件.

我找到了命令:

diff [-c M | -r N[:M]] [TARGET[@REV]...]

diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] [PATH...]

diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
Run Code Online (Sandbox Code Playgroud)

但我不明白是什么target[@rev], [--new=NEW-TGT[@NEWREV]] [PATH...]意思.

假设我检查了文件/home/svn/myproject/test.c并对其进行了一些更改.现在我想检查存储库中的那个和这个.我怎么做?提前致谢!

linux svn diff

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

python使用argparse.ArgumentParser方法

我试图学习如何argparse.ArgumentParser工作,我为此写了几行:

global firstProduct
global secondProduct 
myparser=argparse.ArgumentParser(description='parser test')
myparser.add_argument("product1",help="enter product1",dest='product_1')
myparser.add_argument("product2",help="enter product2",dest='product_2')

args=myparser.parse_args()

firstProduct=args.product_1
secondProduct=args.product_2
Run Code Online (Sandbox Code Playgroud)

我只是想,当用户运行此脚本有两个参数我的代码并将其分配给firstProductsecondProduct分别.但它不起作用.有人告诉我为什么吗?提前致谢

python command-line argparse

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

将字符串拆分为向量c ++

我写了一个简单的代码来分割每个'/'的字符串并存储到vector中.我的字符串可以以/或不开头,并且definetelly将以/结尾.例如,如果我的字符串是:

string="/home/desktop/test/" 
I want to <"/","home","desktop","test"> and another example

string="../folder1/folder2/../pic.pdf/" 
I want to store <"..","folder1","folder2","..","pic.pdf"
Run Code Online (Sandbox Code Playgroud)

但是,我的代码给了我 <" ","home","desktop","test"," ">第一个例子和 <"..","folder1","folder2","..","pic.pdf"," ">第二个例子

有人帮我吗?这是我的代码:

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    string strLine("/cd/desktop/../test/");
    string strTempString;
    vector<int> splitIndices;
    vector<string> splitLine;
    int nCharIndex = 0;
    int nLineSize = strLine.size();

    // find indices
    for(int i = 0; i < nLineSize; i++)
    {
        if(strLine[i] == '/')
            splitIndices.push_back(i);
    }
    splitIndices.push_back(nLineSize); // end index

    // fill split lines
    for(int i = …
Run Code Online (Sandbox Code Playgroud)

c++ string split vector

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

使用strptime转换字符串到时间但得到垃圾

我在c ++中使用strptime()函数时遇到问题.

我在stackoverflow中找到了一段代码,如下所示,我想在struct tm上存储字符串时间信息.虽然我应该获得关于我的tm tm_year变量的年份信息,但我总是得到垃圾.有人帮我吗?提前致谢.

    string  s = dtime;
    struct tm timeDate;
    memset(&timeDate,0,sizeof(struct tm));
    strptime(s.c_str(),"%Y-%m-%d %H:%M", &timeDate);
    cout<<timeDate.tm_year<<endl; // in the example below it gives me 113
    cout<<timeDate.tm_min<<endl; // it returns garbage 
**string s will be like "2013-12-04 15:03"**
Run Code Online (Sandbox Code Playgroud)

c++ strptime

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

如何找到所有最短的路径

我有一个图表,我想找到两个节点之间的所有最短路径.我在BFS找到了两个节点之间的最短路径.但是,它只是给我一条最短路径,如果存在一条以上.

我怎么能使用BFS获得所有这些?

我已经从众所周知的BFS伪代码实现了我的代码.
此外,我有一个邻接列表向量,它包含所有节点的邻接顶点.

algorithm shortest-path

6
推荐指数
3
解决办法
7942
查看次数

在具有多个路径的两个修订之间获取日志消息

我想获取软件包的两个修订版本之间的日志消息,但是其中一个位于路径中http://blablabla/development/packagename,另一个位于中http://blablabla/tag/packagename

我想我必须给给出两个路径和两个修订号svn log,但是我不知道该怎么做。如果有可能,我将如何去做?

svn logging revision

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

将vector的内容写入文件c ++

我试图将我的矢量内容写入文件.为此,我写了一段代码,如:

int main()
{
    ofstream outputfile("test.txt");
    vector<int>temp;
    temp.push_back(1);
    temp.push_back(2);
    temp.push_back(3);
    for(int i=0;i<temp.size();i++)
        outputfile<<temp[i]<<"\n";
}
Run Code Online (Sandbox Code Playgroud)

当我写这篇文章时,我可以轻松地做我想要的.文件内容是:

1 2 3

但是,当我想从反向编写我的矢量文件时(如下所示).我什么都没得到.只是空文件.有没有人帮我?提前致谢.

for(int i=temp.size()-1;i>=0;i--)
    outputfile<<temp[i]<<"\n";
Run Code Online (Sandbox Code Playgroud)

c++ file-io

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

using .o files in makefile

I've just learn something about makefile and here is my first question for it.I have main.cpp hello.cpp factorial.cpp and functions.h files

all: hello

hello: main.o factorial.o hello.o
    g++ main.o factorial.o hello.o -o hello

main.o: main.cpp
    g++ -c main.cpp

factorial.o: factorial.cpp
    g++ -c factorial.cpp

hello.o: hello.cpp
    g++ -c hello.cpp

clean:
    rm -rf *o hello
Run Code Online (Sandbox Code Playgroud)

In the code above, why files have an extention .o ? shouldnt be .cpp or what is the differences between using .cpp and .o

c++ makefile

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

包含对象的c ++结构

我想创建一个结构,让我们说Mystruct,它包含一个整数和一个myObj对象,其构造函数有两个参数(一个是字符串,另一个是int).我的意思是我想:

struct Mystruct{
   myObj obj();
   int a;
};
Run Code Online (Sandbox Code Playgroud)

现在,经过一些操作,我想创建一个Mystruct变量并初始化obj和a.为此,我写道:

struct Mystruct* foo;
foo->a=5;
foo->obj=myObj("test",3);
Run Code Online (Sandbox Code Playgroud)

这是一个好方法吗?

c++ oop struct

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