Can't open csv file and dsiplay it

Pages: 12

ah thanks for the correction, i missed that, compiles great

You're using set wrong. See my previous post code lines 252-257.
What do these errors mean while trying to show?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int showName(Goalies *w_ptr, int count)
{
    /* Display the headings for each column, with spacing and justification flags */
    printf("%s%15s%25s%8s%20%15\n", "Name", "Team", "Wins", "Losses", "Goals Allowed", "Shots Against");

    // Read widget data from file using ',' as a delimiter.
    for (int i = 0; i < count; i++) {

        if (w_ptr->setName.c_str() != 0) {
            printf("%-8d%-30s%-10d%-2.2f%-15%-20,\n",
                    w_ptr->setName.c_str(),
                    w_ptr->setTeam.c_str(),
                    w_ptr->setWins,
                    w_ptr->setLosses);

            w_ptr++;
        }
        /* If the Name field is zero, then we reached the last player, break
         * out of the for loop.
         */
        else
            break;
    }
}

Last edited on
I'm not sure what these errors mean in my show function


Errors:

||=== Build: Debug in prog3 (compiler: GNU GCC Compiler) ===|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp||In constructor 'Goalies::Goalies()':|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp|11|warning: statement has no effect [-Wunused-value]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp|12|warning: statement has no effect [-Wunused-value]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp||In function 'void split(const string&, char, std::vector<std::__cxx11::basic_string<char> >&)':|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|142|warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|160|warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp||In function 'int showName(Goalies*, int)':|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|174|warning: conversion lacks type at end of format [-Wformat=]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|174|warning: unknown conversion type character '\x0a' in format [-Wformat=]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|174|warning: too many arguments for format [-Wformat-extra-args]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|179|error: invalid use of member 'void Goalies::setName(std::__cxx11::string)' (did you forget the '&' ?)|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|179|error: expected ')' before 'c_str'|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|181|error: invalid use of member 'void Goalies::setName(std::__cxx11::string)' (did you forget the '&' ?)|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|182|error: invalid use of member 'void Goalies::setTeam(std::__cxx11::string)' (did you forget the '&' ?)|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\main.cpp|194|warning: no return statement in function returning non-void [-Wreturn-type]|
||=== Build failed: 4 error(s), 8 warning(s) (0 minute(s), 0 second(s)) ===|


Last edited on
Change set to get !

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int showName(Goalies *w_ptr, int count)
{
    /* Display the headings for each column, with spacing and justification flags */
    printf("%s%15s%25s%8s%20%15\n", "Name", "Team", "Wins", "Losses", "Goals Allowed", "Shots Against");

    // Read widget data from file using ',' as a delimiter.
    for (int i = 0; i < count; i++) {

        if (!w_ptr->getName().empty()) {
            printf("%-8d%-30s%-10d%-2.2f%-15%-20,\n",
                    w_ptr->getName().c_str(),
                    w_ptr->getTeam().c_str(),
                    w_ptr->getWins(),
                    w_ptr->getLosses());

            w_ptr++;
        }
        /* If the Name field is zero, then we reached the last player, break
         * out of the for loop.
         */
        else
            break;
    }
}


Why are you using c printf rather than C++ cout??
Several times now, your build output has included the following warnings:

C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp||In constructor 'Goalies::Goalies()':|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp|11|warning: statement has no effect [-Wunused-value]|
C:\Users\Chris Valvo\Dropbox\My PC (DESKTOP-1NVD3NT)\Documents\c++\prog3\Goalies.cpp|12|warning: statement has no effect [-Wunused-value]|

What's causing those? You should be concerned about that.
I'm going to guess it's these fine lines that do nothing:

1
2
 goalsAllowed;
 shotsAgainst;
Topic archived. No new replies allowed.
Pages: 12