pls help just started learning c++ and cant get my head around how to do this:
write prog for data logger which records one reading per day at a specific time for 5 days.the logger records in the format:n1805071500
the first letter preceding the numbers can mean one of below
n= normal
g=high
l=low
the rest are day,month,year,time.
the info can be extracted in the form of text filecontaining 5 lines

x=missed/invalid

  • prog to display welcome msg
  • TO DISPLAY ALL DATA ON SCREEN IN TABLE FORM BY COMMAND T(HINT USE\t for tabs)
  • should show bar chart on command G,showing number of occurremcesof normal,high,low,missed measuremnts in the form of *,each asterik representingone instance
  • user should request for particular days using command D
  • Exist using command Q
  • any command other than T,D,G,Q will result in error and request for new input

GIVEN CODEREADS LINES FROM TXT FILE"LOG.TXT" AND STORES EACH CHARACTER INDIVIDUALLY IN A 2D ARRAY WHERE THERE ARE 11 COLUMNS AND 5 ROWS.ONE ROW OF CHARACTERS FOR EACH DAY
#include<stdio.h>
main()
/* variable declarations*/
FILE* f;
char s[57];
char v[5][11];
int i,j,k;
/*initialise variables*/
i-0;
j=0;
k=0;
/*open file fore reading*/
f=open("log.txt","r");
/*until end of file is reached*/
while (fgets (s,57,f)!=NULL)
{
do{
/*add file character to array column*/
v[j]=s[k];
/*move on one array column*/
j++;
k++;
/* for 11 characters in one row*/
}while (j<12);
/*move to next row*/
i++;
/*set column counters back to zero*/
k=0;
j=0;
}
/*close file*/
fclose(f);
PLEASE HELP IN CREATING CODE
**********my attempt is shown below***********************************
/*program to input datalogger results*/
#include<stdio.h>
#define DURATION 5
main()
{
int day;
float reading[DURATION];


for(day=0;day<DURATION;day++)
{
printf("welcome to data dst datalogger\n ");
printf("please enter day\n");
}

}

Member Avatar for iamthwee

Just wondering how are you doing the time part? Are you using the time library or an OS specific function?

First off, you might want to put this in the C++ section, and also put the code into [ code ] tags, because the code is hard to use otherwise.

I'll look this over in a little bit.

Member Avatar for iamthwee

>which records one reading per day at a specific time for 5 days.

Er, I was just wondering do you actually have to do the above, or just parse the info from your text file?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.