C/C++ :: Get Current Time And Write It To A File?

Jul 19, 2013

i have to write the current time to a file ?how to do it

View 2 Replies


ADVERTISEMENT

C++ :: Read From Txt File One Bit At A Time And Then Write Into Binary File

Apr 22, 2013

I am trying to get the code to read from the txt file one bite at a time and then write this bite into the binary file but i cant seem to get it working.

FILE *fpcust, *fpcustbin; //<<<<<-----point to both sales and customers text files, and the new .bin files for both
char buffer;
int ch;
int ch1;
fpcust = fopen("c:customers.txt", "r"); //<<<<-----pointing to the file
fpcustbin = fopen("c:customers.bin", "wb"); //<<<<<-----pointing to the new binary file, opening in writing binary

[Code]...

View 3 Replies View Related

C++ :: Program To Display AM/PM With Current Time?

Feb 14, 2013

I'm trying to display the AM/PM on my program:

Also is there a way to display the time only instead of the date? How will i change the program to display the time in standard 12 hours, instead of 24 hours?

#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t tim;
time(&tim);
cout << ctime(&tim);
}

View 1 Replies View Related

C++ :: School Project - Getting Current Date And Time

Dec 30, 2014

I am doing a school project. The project basically is that it records the in and out time of an employee(of an particular company).The employee while checking in or out should enter a unique key generated specially for him so that no one else can check in and out for him.Then referring to the employees position( A worker or a manager or something like that) his total working time each day , for a week and a month is calculated. The company starts at 8 am and ends at 5 pm for 1st shift and for second shift from 3.30 pm to 2.30 am. Plus Saturday and Sunday off. Then after a month the program refers to the working time date stored in a file and calculates his pay(For workers its per hour salary and for managers it aint).

If an employee is consistently late the details are forwarded to the HR account( so that necessary steps are taken).This will support the company log the details of their employees duty time plus give enough detail to take action if someones always late. I'm doing this as a school project and it needn't be of enterprise class and all.. But i want the coding to perform as it should. Also i'm forced to use the old Turbo C++. Now i'm struck in the place where the time of the employees in and out time is logged. This coding does the work

Code:
void main( ) {
clrscr();
char dateStr [9],timeStr [9];
_strdate( dateStr);
cout<<" The current date is "<<dateStr<<'

[Code] ....

I think the second one is better as it not only gives me date but also gives me the day so i can check easily for the weekends. So, how these time functions work.

View 1 Replies View Related

C :: Printing Current TIME At Regular Intervals

Aug 22, 2013

Its a code in module of my program, where I need to print current time (HH:MM:SS) at regular intervals.

Code:
#include<time.h>
#include<stdio.h>
//#include<windows.h>
void delay(unsigned int t){ // loop for some delay.

[Code] ....

But when I am running this code I expect this to print difference in time due to delay. But it doesn't enter the delay loop, why ?

View 5 Replies View Related

C++ :: Write A Program That Gives Current Calendar

Jan 14, 2014

I have a problem. I want to write a program that gives me the current calender for example like this:

June 2009

Su Mo Tu We Th Fr Sa
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 27
28 29 30

and I shouldn't use windows.h

View 2 Replies View Related

C/C++ :: Save The Current Date And Time Into A Char Array?

Jan 14, 2015

I am trying to use to save the current date and time into a char array using this code:

char current_time(char *date){
time_t result = time(NULL);
date = ctime(&result);
return *date;
}
main{

[Code]...

now when I output the date char array into a txt file I only get gibberish.

View 6 Replies View Related

C :: Display Current Time And Date In Program And Use Variable To Store Each Of Values

Feb 16, 2013

i need to display the current time and date in my program and use variable to store each of the time values like

a = 10
b = 29
c = 31

printf(``%d : %d : %d``, a,b,c);

which then give the output as - 10:29:31

How to save the time in variables in C....

i am using C in windows 7 and my complier is Bloodshed Dev C++

View 7 Replies View Related

Visual C++ :: Getting Name Of Current Save File?

Oct 10, 2014

When I have loaded a savefile with Serialize, is there some way of telling the name of the currently loaded savefile?

View 2 Replies View Related

C Sharp :: Copying A File From Current Directory To System Drive

Feb 8, 2014

I have tried to use File.Copy and File.Move but non of them would work as I expected .....

View 1 Replies View Related

Visual C++ :: Launching Current Version Of IE To View HTML File From Program

Nov 29, 2012

I tried to do this with _spawnl(), but first of all I'm not sure how to properly ask for the path to iexplore.exe, as I'm sure it will change every time MS gets a whim to move it. I know there's a GetWindowsDirectory() call, but that's not where IE resides (its in "C:Program FilesInternet Exploreriexplore.exe" in XP, Lord know where on win 7 or 8).

Also, even temporarily hard coding the path to make it launch with spawnl(), I can't seem to get my html document to display. I know the path to that is right (since I put it there ).

char * pFile = "someFile.htm";
char * pCmd = "C:Program FilesInternet Exploreriexplore.exe";

int res = _spawnl(_P_NOWAIT, pCmd,pCmd, pFile, NULL); // also tried without specifying pCmd 2x
if (res == -1) MessageBox("Can't Open File.");

So my second question would be, how to you PROPERLY pass the file to view as an argument.

View 7 Replies View Related

C++ :: Write Program To Convert Time From 24-hour Notation To 12-hour Notation

Dec 10, 2013

Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)

Answer:

#include <iostream>
#include <iomanip>
#include <cmath>

[Code]....

It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.

View 2 Replies View Related

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[Code]....

View 2 Replies View Related

C :: Create File To Write Text And Read Back The File Content

Mar 15, 2013

The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.

How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?

If "Y" Than Inputs Are Taken From Next Line Else Input Ends.

But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.

Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){

[Code].....

View 5 Replies View Related

C++ :: Decompress Input File And Write Results Into Output File?

Jul 8, 2013

how do i decompress an input file and write the results into an output file?

also my do while loop is supposed to keep going unless the user selects the option to exit the program, instead it exits after finishing ay of the options.

here's my code so far...

#include <iostream>
#include <iomanip>
#include <fstream>

[Code]....

View 1 Replies View Related

C++ :: Read From A Txt File And Then Write A New Text File With Sorted Line

Jun 11, 2014

I have a .txt file which I want to read from and then write a new text file, this time with sorted lines. It is easy to sort one value, but what about sorting entire lines based on one value?

I want to sort the lines based on the FIRST value.

Example text file contents:

values;data
5.01 100
2.9 342
2.69 43534
10.1 43
6.8 45324

Output: Text file containing

2.69 43534
2.9 342
5.01 100
6.8 45324
10.1 43

It's easy to do this if there was only 1 number on each line, but I do I sort all the lines based on the first number in each line?

View 2 Replies View Related

C/C++ :: Program To Compute Students Grades From File And Write Them To File?

Aug 31, 2014

We have to write a program that reads an input file containing data in the form:

Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...

and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.

Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.

Here's the code that I have so far.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];

[code]....

Do I need to re-read the input file and assign them to different variables?

Here's a sample of the output so far:

Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0

Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.

View 2 Replies View Related

C++ :: Write Negative To One File And Positive Numbers To Another File

Dec 11, 2013

im supposed to create a program that reads in a list of integers from the terminal and writes the negative numbers to one file and the positive numbers to another file.

i got most of it doen but for some reason its not writting the negative numbers. on what im doing wrong?

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
int pos_num = 0;
int neg_num = 0;
int positive_numbers = pos_num % 5;

[Code]...

View 2 Replies View Related

C/C++ :: Round Robin Execution With Gantt Chart - Arrival Time And Burst Time

Mar 10, 2015

This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??

#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;

[Code] ....

View 2 Replies View Related

C++ :: Using FILE Class To Write Into Txt File In DOS Codepage

Dec 8, 2013

I'm using

CString text;
CString file_name;
text = "My text.";
file_name = "MyFile.txt";
FILE *fp;
fp = fopen(file_name, "w+");
fprintf(fp, text + "
");
fclose(fp);

There will be MyFile.txt in Windows codepage.

How to write to txt file with DOS codepage?

View 9 Replies View Related

C++ :: Read One Value At A Time From A File

Sep 27, 2013

I'm trying to read in one value at a time from a file with this function, but its giving me back junk.

javascript:tx(
void ReadValue (istream &inF, int & num, bool & success) {
inF.clear();
inF.seekg(0L, ios::beg);
inF >> num;
cout << num;

[Code] .....

View 4 Replies View Related

C++ ::  Printing From File One Word At A Time

Jun 27, 2013

I have done an exercise from "Thinking in C++" to print text from a file to the console one line at a time, with the user pressing enter to get the next line.

My original code is below, how could I change it for one word at a time?

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

[Code] .....

I tried to alter my program to print one word at a time by changing "getline(in, word)" to "in >> word", but it prints each new word on a new line, the only input I have found to make the next word appear is Enter, I assume that's why.

Is there a way to make it print one word at a time when the user says, but on the same line?

View 4 Replies View Related

C++ :: Read One Number At A Time From Int File?

Sep 15, 2013

I have a file called example.txt . In that file, the int 123456 is stored. How can I read one independent number from that int? Lets say, I have an int variable called "Weight." How do I set weight equal to the number 1 from the int 123456 in the file?

View 4 Replies View Related

C++ :: Reading Certain Numbers At A Time From Int File

Sep 15, 2013

I am reading certain int's at a time from one int number stored in a file. I'll explain. I am working on an ezpass project and basically I have to store an int in a file, and from that file, write a program that separates numbers into information.

For example:

the number 204601324 is stored in a file. I know how to open a file from terminal, but the issue is reading the individual numbers. The first number is weight class (2). My program has to display that number as the Variable "weightClass." how do I get it to do that? In addition, miles allowed is the number "0460." How do I get that number to display as the variable "oMiles?"

View 1 Replies View Related

C/C++ :: Best Way To Read One Bit At A Time From A Binary File?

Nov 9, 2013

I'm trying to do file compression/decompression in C and I need to handle one bit at a time.

I currently try to do:

unsigned char byte = fgetc(fptr);

and later

byte >>= 1;

but the problem is that I have to use the first bit of the byte and then treat the next 8 bits as one byte. The byte usage keeps shifting over in this way. It's probably quite clear that I'm a bit lost.

View 1 Replies View Related

C/C++ :: Write BST To File

Nov 12, 2014

I can only write one value to file:

get all, say for example barcode
char* bst:: get_bar(hwareItem*& root){
while(root!=NULL){
get_bar(root->left);

[Code]...

gets only one value depending on traversal orderI wish to get all values of BST

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved