0
I really need help with my assignment. Anyone willing to help me... can't get through my functions
C programming
5 Antworten
+ 1
Please show your attempt here.
+ 1
It may be more easy to understand your code if you will write in Sololearn Playground.
And please add more description about what you want to get as output.
Please write in Sololearn Playground and share code here.
+ 1
Thanks ~ swim ~ . i expected the same but i don't tried before. That's why thought how to specify path? from where to? It means we can create files but not possible to store for read later...
Thank you for clearing my doubt...
0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define GROUP_SIZE 10
typedef struct {
int Robot_Number;
char Robot_Name [20];
int Year_Manufacture;
float Top_Speed;
float Mass;
float Best_Score;
} robot_t;
int main()
{robot_t robot_info[10]={{1, "Adminbot", 1999, 15.00,110.00,0.0},
{2, "BrainAT", 2010, 32.50, 18,0.0},
{3, "BOBBY", 2013, 29.50, 7.50,0.0},
{4, "MiMi", 2018, 40.00,8.80,0.0},
{5, "YesBOT", 2019, 40.50, 70.00,0.0}};
int i=0, no_of_robots=0;
robot_t robot_info[10];
//open the robot file to read
FILE* inputfile = fopen("Robot.txt", "r");
if(inputfile == NULL)
{
printf("ERROR! the file failed to open\n");
exit(-1);
}
int Number;
char Robot_n[20];
int Year_m;
float Top_s;
float Mas;
float Best_s;
//read robot info from a file
while(fscanf(inputfile, "%d %19s %d %f %f %f", &Number, Robot_n, &Year_m, &Top_s, &Mas, &Best_s)==6){
robot_info[i].Robot_
0
This is what I did... could do the switch function