小编Per*_*ulf的帖子

如何在c中打印pdf文件?

我正在做一个关于通过c打印文件的小项目.

我使用linux作为Os.一切正常,但我无法找到pdf格式的任何解决方案.我可以用这个库吗?

c pdf

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

unicode和python问题(访问unicde代码图表)

昨天我写了以下内容function转换integerPersian

def integerToPersian(number):
    listedPersian = ['?','?','?','?','?','?','?','?','?','?']
    listedEnglish = ['0','1','2','3','4','5','6','7','8','9']    
    returnList = list()

    listedTmpString = list(str(number))

    for i in listedTmpString:
        returnList.append(listedPersian[listedEnglish.index(i)])

    return ''.join(returnList)
Run Code Online (Sandbox Code Playgroud)

当你调用它,如:integerToPersian(3455),它return ????????就相当于3455PersianArabic language。当你看一个数字,如阅读databae,并希望显示widget,这 function是非常有用的。

我从http://unicode.org下载codes charts 了,因为我需要写,因为它应该作为参数存储,所以我是pytho中的新手。unicodePersianToInteger('unicodeString')utf-8utf-82 bytes

我的问题是,如何存储2bytes?,如何utf8存储,如何将一个拆分unicode string为另一种格式?怎么用unicode code charts

注意:我发现使用int() built-in fuinction,但是我无法使用。也许可以

python unicode utf-8 unicode-string python-unicode

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

C - valgrind - 大小为1的读取无效

我在使用Valgrind调试代码时遇到了一些麻烦.以下是出现错误的结构和主要部分:

struct trieNode {
    char *word;
    struct trieNode *(subNode[LEAF_NUM]);
    struct sharpNode *sharp;    
};


//linked list of sharp(s)
struct sharpNode {
    char *word;
    struct sharpNode *next;
}; 
Run Code Online (Sandbox Code Playgroud)

if (head->word == NULL){ 
    //strlen(head->word) == 0){
    head->word = (char *)malloc(MAX_LEN * sizeof(char));     //LINE 191
    //memset(head->word, '\0',strlen(head->word));
    strncpy (head->word, word, strlen(word));

} else { 

    if (head->sharp == NULL) {
        head->sharp = sharpNodeCreate();
        head->sharp->word = (char *)malloc(MAX_LEN * sizeof(char));    //LINE 200
        //head->sharp->word[strlen(word)] = '\0';
        strncpy (head->sharp->word, word, strlen(word));
    }

}
Run Code Online (Sandbox Code Playgroud)

            } else if ( sharpIndex …
Run Code Online (Sandbox Code Playgroud)

c profiling valgrind

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

从拥抱类型获取模板参数的值

说,我有一个带有整数参数的模板类:

template <int N>
class A
{
public:
    static int get_N()
    {
        return N;
    }
};

template<typename T>
class B
{
public:
    B()
    {
        cout << "N = " << T::get_N() << endl; // Accessing N via the auxiliary method
    }
};
Run Code Online (Sandbox Code Playgroud)

要在类BI中引用N模板参数,必须在A中创建一个辅助方法.我想做这样的事情:

template <int N>
class A
{
};

template<typename T>
class B
{
public:
    B()
    {
        cout << "N = " << T::N << endl; // Accessing N directly
    }
};
Run Code Online (Sandbox Code Playgroud)

问题是我将有很多A模板特化,我真的不想将这个辅助方法复制到所有专门的类,我不想为此引入继承.有可能实现我想要的吗?

c++ templates template-specialization

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

__gt__ vs &gt; and so on

some python classes have some operators such __gt__ or __lt__, They have been named from fortran language.

What's difference between above operators and < or > ?
Is't better to use __operators__ than < or > ?

python operators

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

使用std :: vector <std :: pair <>>查看向量

我有以下向量:

std::vector< std::pair<std::string,bool > > myvec;
Run Code Online (Sandbox Code Playgroud)

如何使用迭代器浏览和打印矢量元素?

c++ oop iterator vector std-pair

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

如何grep文件中的变量?

我想知道如何在文件中输出(排除)变量?

例如file.txt:

PATH1=/path/to/file
PATH2=/path/to/anotherfile
PATH3=/path/to/thirdfile
TEST=$(echo $RANDOM)

* * * * *\5 top -n 1 > /tmp/$TEST
* * * * * echo hello # = for deletion
Run Code Online (Sandbox Code Playgroud)

我想只打印没有变量的cron作业:例如:

* * * * *\5 top -n 1 > /tmp/$TEST
* * * * * echo hello # = for deletion
Run Code Online (Sandbox Code Playgroud)

请注意,最后有相同的标志,我也需要保留这些线.拖尾这个文件不是一个解决方案,当然不仅仅有一行不是变量.有任何想法吗?

bash shell grep

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