Question

C++ How would i set the database entries to 0? void InitDatabase(Database& database); - - database.h...

C++

How would i set the database entries to 0?

void InitDatabase(Database& database);

-

- database.h is

const int CAPACITY = 10000;

struct Record {

string word;

int occurrenceCount;

int scoreTotal;

{;

struct Database {

Record records[CAPACITY];

int countWords;

{;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You can do like this :-


void InitDatabase(Database& database){

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

database.records[i].word = "";

database.records[i].occurrenceCount = 0;

database.records[i].scoreTotal = 0;

}

database.countWords = 0;

}

SEE OUTPUT

PLEASE COMMENT if there is any concern.

=============================

Add a comment
Know the answer?
Add Answer to:
C++ How would i set the database entries to 0? void InitDatabase(Database& database); - - database.h...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • How would I test this code thoroughly in a main.cpp file. Locomotive is an abstract base...

    How would I test this code thoroughly in a main.cpp file. Locomotive is an abstract base class. steam and dieselElectric are the derived classes. #ifndef COMMODITY_H #define COMMODITY_H #include <iostream> #include <string> using namespace std; class commodity { private:    string name;    int quantity; public:    commodity(commodity *c);    commodity(string name,int quantity);    ~commodity();    string getName() const;    int getQuantity() const; }; #endif #include "commodity.h" commodity::commodity(commodity *c) {       this->name=c->getName();    this->quantity=c->getQuantity(); } commodity::commodity(string name,int quantity) {       this->name=name;   ...

  • C++; Header file // ------------------------------------------------------------- // // Set resultString[] to a string value that is a...

    C++; Header file // ------------------------------------------------------------- // // Set resultString[] to a string value that is a copy of a specified substring of original string s. // If specified start position is not located within the string s, then set resultString to the empty string (""). // If specified len < 0, or if (start + len) > the length of s, then set resultString to the longest possible substring. void stringSubstring(         char resultString[ ], // new string buffer...

  • C++ assignment help! The instructions are below, i included the main driver, i just need help...

    C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...

  • Hardware Inventory – Write a database to keep track of tools, their cost and number. Your...

    Hardware Inventory – Write a database to keep track of tools, their cost and number. Your program should initialize hardware.dat to 100 empty records, let the user input a record number, tool name, cost and number of that tool. Your program should let you delete and edit records in the database. The next run of the program must start with the data from the last session. This is my program so far, when I run the program I keep getting...

  • This is for my c++ class and im stuck. Complete the Multiplex.cpp file with definitions for a fun...

    This is for my c++ class and im stuck. Complete the Multiplex.cpp file with definitions for a function and three overloaded operators. You don't need to change anything in the Multiplex.h file or the main.cpp, though if you want to change the names of the movies or concession stands set up in main, that's fine. Project Description: A Multiplex is a complex with multiple movie theater screens and a variety of concession stands. It includes two vectors: screenings holds pointers...

  • Concurrent Key-Value Database Implement a non-persistent, concurrent key-value database using the Reader/Writers algorithm. - Use a...

    Concurrent Key-Value Database Implement a non-persistent, concurrent key-value database using the Reader/Writers algorithm. - Use a hashmap as the underlying data structure. Inspiration is ok, however the implementation must be yours. The hashmap must be able to grow to fit new elements, but it does not need to reduce its size. -- Linked lists? Positional arrays? All are fine. - Keys and values are strings (char *) - Operations are: get, put Provided files: - Implement the contract set in...

  • Write the C module intSet to implement an unordered set of integers according to the specification...

    Write the C module intSet to implement an unordered set of integers according to the specification given below. File intSet.h (downloadable off the class web pages): #ifndef INTSET_H #define INTSET_H typedef struct intsetType *intSet; intSet createSet(); // returns an intSet created at runtime using malloc void destroySet(intSet); // frees up the memory associated with its argument void clear(intSet); // clears set to empty (freeing any memory if necessary) int card(const intSet); // returns the cardinality of the set bool equals(const...

  • Write the C module intSet to implement an unordered set of integers according to the specification...

    Write the C module intSet to implement an unordered set of integers according to the specification given below. File intSet.h: #ifndef INTSET_H #define INTSET_H typedef struct intsetType *intSet; intSet createSet(); // returns an intSet created at runtime using malloc void destroySet(intSet); // frees up the memory associated with its argument void clear(intSet); // clears set to empty (freeing any memory if necessary) int card(const intSet); // returns the cardinality of the set bool equals(const intSet,const intSet); // returns true if...

  • C++ language I need to update this code with the following: ask the user for how...

    C++ language I need to update this code with the following: ask the user for how many structures they would like. Once you get the number, allocate an array of pointers. Once they have been created, proceed to loop through and get the data as usual, and display it back to the screen. struct record {    int age;    string name; }; int check(record r[], int n, string nm) {    for (int i = 0; i < n;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT