小编gam*_*l22的帖子

在Eclipse中使用argc和argv?

我有一个工作程序,但现在我必须使用int argcchar *argv[]参数main.每当我尝试这样做时,它会给我带来无法保存的错误.有没有办法在Eclipse中制作argcargv工作?

c++ eclipse argv argc

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

c ++在将数组读入结构时遇到麻烦

我正在读取数据到结构数组.数据由可能的空行分隔,我必须忽略.我的代码不工作我想知道为什么

struct Location
{
string state;
string city;
int zipcode;
}
Run Code Online (Sandbox Code Playgroud)

并且继续阅读我的麻烦.

while (!fin.eof() && size < 50)
{
getline (fin, location[size].state);
getline (fin, location[size].city);
fin >> location[size].zipcode;

if (location[size].empty()) //to ignore blank lines but its not working?
continue;
size++;
    }
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?它可能是编译器吗?

c++ multidimensional-array

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

c ++如果我的程序在eclipse上运行它会在linux上运行吗?

我有一个关于eclipse的工作程序,但我的教授计划通过linux运行它.这是否意味着我必须做所有argc argv的东西?如果是这样的话,我很好.但是,如果它可以在Linux上运行而没有这样做甚至更好,因为argc argv有时候有点令人困惑.

有人知道我的程序是否会运行?

这些是我的头文件:

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <cstdlib>
#include <limits>
#include <algorithm>
#include <vector>
#include <ostream>
Run Code Online (Sandbox Code Playgroud)

c++ linux

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

如何在没有指针的情况下传递一个struct数组?C++

你好,我对如何在不使用指针的情况下通过带有结构的函数正确传递数组感到困惑.我们只应该使用第1-8章,其中不包括指针..这里是我的代码,如果有人有任何建议或链接,以帮助谢谢!

const int MAX_DATA = 10000;

struct Inventory
{
   double sku;
   double count;
   double cost;
   string title;
};

void addMovie(Inventory data[], double count);
void allInfo(Inventory data[], double count);

int main ()
{
   Inventory data[MAX_DATA];
   int choice;
   int i = 0;
   double count = 0;
   return 0;
}

void addMovie(Inventory data[], double count)
{
int i = 0;

cout << "Please enter the name of the movie you wish to add " << endl;

cin >> data[i].title;
cin.ignore();
cout << "Please …
Run Code Online (Sandbox Code Playgroud)

c++ arrays structure function

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