
Concept explainers
C


Step by stepSolved in 4 steps with 3 images

I need the script to create a txt file thats made up of all the individual entries as well as the individual txt files for each entry.
The script pasted below prints individual entries but I need it to print 1 additional txt file thats like a sum of all the other created txt files. Thank you!
//script:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME_LENGTH 50
#define MAX_WARRIORS 7
//Usagi Tsukino 1.98
//Rei Hino 3.2
//Amy Mizuno 4.0
//Makoto Kino 2.9
//Minako Aino 2.21
//Haruka Tenou 3.5
//Michiru Kaiou 3.78
struct SailorWarrior {
char name[MAX_NAME_LENGTH];
char name2[MAX_NAME_LENGTH];
float gpa;
};
int main() {
struct SailorWarrior warriors[MAX_WARRIORS];
char filename[MAX_NAME_LENGTH + 5]; // +5 for ".txt\0"
int i;
for (i = 0; i < MAX_WARRIORS; i++) {
printf("Enter the name and GPA for Sailor Warrior #%d: ", i+1);
scanf("%s %s %f", warriors[i].name,warriors[i].name2, &warriors[i].gpa);
sprintf(filename, "%s.txt", warriors[i].name); // create filename
FILE* fp = fopen(filename, "w"); // create file
if (fp == NULL) {
printf("Failed to create file for Sailor Warrior %s\n", warriors[i].name);
continue; // skip to next iteration of loop
}
fprintf(fp, "Name: %s %s\nGPA: %.2f\n", warriors[i].name,warriors[i].name2, warriors[i].gpa);
fclose(fp); // close file
}
return 0;
}
I need the script to create a txt file thats made up of all the individual entries as well as the individual txt files for each entry.
The script pasted below prints individual entries but I need it to print 1 additional txt file thats like a sum of all the other created txt files. Thank you!
//script:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME_LENGTH 50
#define MAX_WARRIORS 7
//Usagi Tsukino 1.98
//Rei Hino 3.2
//Amy Mizuno 4.0
//Makoto Kino 2.9
//Minako Aino 2.21
//Haruka Tenou 3.5
//Michiru Kaiou 3.78
struct SailorWarrior {
char name[MAX_NAME_LENGTH];
char name2[MAX_NAME_LENGTH];
float gpa;
};
int main() {
struct SailorWarrior warriors[MAX_WARRIORS];
char filename[MAX_NAME_LENGTH + 5]; // +5 for ".txt\0"
int i;
for (i = 0; i < MAX_WARRIORS; i++) {
printf("Enter the name and GPA for Sailor Warrior #%d: ", i+1);
scanf("%s %s %f", warriors[i].name,warriors[i].name2, &warriors[i].gpa);
sprintf(filename, "%s.txt", warriors[i].name); // create filename
FILE* fp = fopen(filename, "w"); // create file
if (fp == NULL) {
printf("Failed to create file for Sailor Warrior %s\n", warriors[i].name);
continue; // skip to next iteration of loop
}
fprintf(fp, "Name: %s %s\nGPA: %.2f\n", warriors[i].name,warriors[i].name2, warriors[i].gpa);
fclose(fp); // close file
}
return 0;
}
- T or F Number fields store values that represent quantities, measurements, and scores, for example. T or F The introduction should be the principal section of a formal report. T or F The Import Spreadsheet Wizard can help you import data from Excel into a new Access table. Which of the following properties can you set for a Short Text field? Format Decimal Places Default Value Input Mask What type of graphic illustrates changes in data over time? Line chart Flowchart Pie chart Tablearrow_forward.</tr> </table> </form></body></html>.arrow_forward<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title><script src="js/practice.js"></script></head><body><h2> Which student would you like to know about?</h2><form><input type="button" name="showResults" onclick="loadData();" value="Click to start"/></form><div id="container">Your results are here</div></body></html> <?phpprint <<<EOF{"employees":[{ "firstName":"Mark", "lastName":"Henry" },{ "firstName":"Joe", "lastName":"Sterna" },{ "firstName":"Pat", "lastName":"Garcia" }]}EOF;?>function loadData() {let results = document.getElementById("container");//results.innerHTML = oStr;alert("Click");loadFromServer( results ) } function loadFromServer( resContainer ){// Use Ajax and xmlHttp to create the following output when you click the buttonxmlHTTP.open("getData.php")document.getElementById("container").innerHTML = this.resposeText;//…arrow_forward
- I need help with the part below and please add comments in the code to help me understand better what I am doing wrong in my own code. I have already created my database and the connection and some of the code but am stuck on these parts."Home" and "Create Account" pages The index.php file will ask the user to log in to the system with a login form If they're already logged in, the home page will NOT show the login form. It will show a "welcome to our store" type of message instead even if they click on the "home" button in the navigation. The create-account.php page has them fill out a form for creating an account. Use real-time JavaScript validation (and regex) to: Verify that the password and "verify password" match as they are typing. Verify that the password contains at least one number and is at least 8 characters long Be sure to display user feedback messages on the screen as they type, e.g.: Password must contain a number Password must be 8 characters long Password and…arrow_forwardMicrosoft Word 2016 comes with several updates and additions. While using Word 2016, which function do you find the most helpful? Explain briefly why you think this is in your best interest.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





