小编Kei*_*son的帖子

如何确定给定文件是一个类文件?

我需要确定给定文件是否是类文件.假设我将扩展名更改为.exe/.xml或其他一些,我需要确定是否给定文件,如果一个类文件将被不同地解析,如果它将是另一个,它将以这种方式解析.

如何读取类文件格式?

c# java

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

错误:开关数量不是整数 C++

尝试编译我的 C++ 代码时遇到问题。由于我还在学习 C++,我仍然不了解大多数高级命令。我试图创建一个程序,询问用户的名字、姓氏、年龄和性别并将其显示给用户。这是我的源代码:

#include <iostream>

int main ()
{
    char firstName[20];
    char lastName[20];
    char age[6];
    char gender[3];

    int i = 0;

    std::cout << "Please enter your full name: ";
    std::cin.getline (firstName, 19, ' ');
    std::cin.getline (lastName, 19);

    std::cout << "Enter your age: ";
    std::cin.getline (age, 5);

    while (i != 1)
    {
        std::cout << "Enter your gender (m/f)";
        std::cin.getline (gender, 2);

        switch (gender)
        {
            case 'm':
                std::cout << "\nHello Mr. ";
                i++;
                break;

            case 'f':
                std::cout << "\nHello Mrs. "; …
Run Code Online (Sandbox Code Playgroud)

c++ string compiler-errors switch-statement

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

相同的shebang不起作用

所以我试图创建一些我想运行的脚本,而不是每次运行时都手动指定解释器.

#!/usr/bin/python
Run Code Online (Sandbox Code Playgroud)

上面是现有脚本上的shebang,它运行得像我想要的那样.

下面是我从头开始编写的脚本的shebang

#!/usr/bin/python
Run Code Online (Sandbox Code Playgroud)

对我来说,他们看起来完全一样,但是运行第二个给了我一个

helloWorld.py: permission denied
Run Code Online (Sandbox Code Playgroud)

两者都是使用kate,utf-8和unix行创建的.两者都与我相同.

有任何想法吗?

python tcsh shebang

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

可能由if语句引起的C++布尔逻辑错误

这是我遇到问题的一段代码的极简化版本.

int i = 0;
int count = 0;
int time = 50;
int steps = 1000;
double Tol = 0.1;
bool crossRes = false;
bool doNext = true;

for (int i=0; i<steps; i++) {

//a lot of operations are done here, I will leave out the details, the only
//important things are that "dif" is calculated each time and doNext either
//stays true or is switched to false

    if (doNext = true) {
        if (dif <= Tol) count++;
        if …
Run Code Online (Sandbox Code Playgroud)

c++ boolean-logic if-statement

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

将结果从线程转储到向量中是否安全?

我正在学习C++ 11的功能,并按照以下几行编写了一些代码

#include <vector>
#include <thread>
using std::thread;
using std::vector;

double Computation(int arg)
{
    // some long-running computation
    return 42.0;
}

double ConcurrentComputations()
{
    const int N = 8; // number of threads
    vector<thread> thr;
    vector<double> res(N);
    const int arg = 123456; // something or other
    // Kick off threads which dump their results into res
    for(int i=0; i<N; ++i)
        thr.push_back(thread ([&res, i, arg]()
                {  res[i] =  Computation(arg); } ));
    // Wait for them to finish and get results
    double …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading c++11

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

在Linux环境中从另一个用C编写的文件调用用C编写的外部函数

我在调用我在 Linux 的 Pico 编辑器中编写的外部函数时遇到问题。程序应该调用外部函数,它们都是用 C 编写的。

#include????

void calcTax()
float calcfed()
float calcssi()
Run Code Online (Sandbox Code Playgroud)

// 存根程序

#include"FILE2"???or do I use"./FILE2"// not sure which to use here or what        extension     the file should have. .c or .h and if it is .h do I simply change the file     name to file.h?
#include<stdio.h>
#define ADDR(var) &var

extern void calctaxes()
int main()
{
}
Run Code Online (Sandbox Code Playgroud)

我正在使用 gcc 进行编译,但它不会编译。两个文件位于同一目录中并且具有 .c 扩展名

我是一名新学生,所以请耐心等待。

c

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

正则表达式为10或13位数

我试过这个,但在这种情况下,也允许使用11和12:

^[0-9]{10,13}$
Run Code Online (Sandbox Code Playgroud)

我只需要10或13.

regex

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

如何组合2个整数以获得1?

我搜索了这个,但我没有在C语言中找到这个问题的明确答案.

想象一下,我有一个int a = 123和另一个int b = 456.

如何组合它们才能获得combine(a, b) == 123456

c

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

如何在函数内使用cin?

我是c ++的新手,我正在尝试制作一个简单的基于文本的游戏.下面的代码应该欢迎用户加入游戏并询问用户是否想要开始游戏.我没有得到任何构建错误,但是当我运行它时,它显示的是一个空白屏幕.我究竟做错了什么?

代码如下:

string D1(string Original)
{
    cin >> Original;
    return Original;
}

int main ()
{
    string Decision1;
    cout << "Welcome to [game name]" << endl;
    cout << "Would you like to start the game?" << endl;
    cout << "Yes/No" << endl;
    string D1(Decision1);
    system("cls");
    if (Decision1 == "Yes")
    {
        cout << "this happens" << endl;
    }
    else if (Decision1 == "No")
    {
        cout << "that happens" << endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

c++ function

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

将int转换为字符串

str2是我需要追加str1的字符串,是我追加的字符串str2.在我追加到最后,str2我需要附加一个数字(int cnt)str2.所以我使用下面的代码,它出现在我的脑海中并且正在运行.这样的代码是不对的,因为我看到了 编译器对库的抱怨的使用string s = lexical_cast<string>(a);itoa (i,buffer,10);实现.

    string str2;
    string str1;
    int cnt;
    str2 += str1 ;
    str2 += char(cnt+48);//cnt converted to ASCII char and appended;
Run Code Online (Sandbox Code Playgroud)

c++ string int

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