I would like to actually have some measure of roughly how long it takes to do a fwrite to a drive. When I do the following:
clock_t begin = clock();
unsigned long long size_t = fwrite(send, 1, transfer_size*sizeof(unsigned long long), wpFile);
clock_t end = clock();
double long elapsed_secs = double long(end - begin) / CLOCKS_PER_SEC;
Unfortunately, I don't get any different result for different transfer size!!!
My guess is that the clock_t , once it issues a fwrite command, some how stops its measurement, and it comes back again, when I am already done with fwrite. I do get the almost same measure, whether my transfer size is 32KB Byte or 16MB ! Which I was indeed expecting to see a huge difference.
I wouldn't really want the exact real timing measure (well off course it will be nice to know); and all I care about is to see some difference in time whether I am doing KB transfer vs MB transfer. Any other function that will give me some rough measurement of the actual time being elapsed for fwrite function?
I have a question. I would like to actually have some measure of roughly how long it takes to do a fwrite to a drive. When I do the following:
clock_t begin = clock(); unsigned long long size_t = fwrite(send, 1, transfer_size*sizeof(unsigned long long), wpFile); clock_t end = clock(); double long elapsed_secs = double long(end - begin) / CLOCKS_PER_SEC;
Unfortunately, I don't get any different result for different transfer size!!!
My guess is that the clock_t , once it issues a fwrite command, some how stops its measurement, and it comes back again, when I am already done with fwrite. I do get the almost same measure, whether my transfer size is 32KB Byte or 16MB ! Which I was indeed expecting to see a huge difference. I wouldn't really want the exact real timing measure (well off course it will be nice to know); and all I care about is to see some difference in time whether I am doing KB transfer vs MB transfer.
Some rough measurement required of the actual time being elapsed for fwrite function?
I am looking for a function or any example that shows elapsed time in seconds and minutes. I didn't find any solution for both OS Win and Linux. I am looking for example that works for both - win and linux.
In my class I'm trying to display the elapsed time as my label on a windows form. I've been reading up on all the different articles online and have tried these three methods all with the same result:
1. Using the System.Timers class 2. Built in Timer sub-class 3. Defining directly inside of my class the StartTime, etc. variables.
All of these still result in the following error: Cross-thread operation not valid: Control 'User_Interface' accessed from a thread other than the thread it was created on.
Currently, my windows form is being called by another class, but I'm not sure if this is the cause of the problem.
This is a sample of the code that I'm currently using to show the elapsed time:
I want to find out the time difference,say i start walking from my home at 23 hr 10 min 25 seconds and I reach destination at 1 hr 10 min 25 seconds.. I know here the time difference is 1 hr 55 min 55 seconds. But how am I gonna calculate this?
I have a problem with calculating the CPUtime. I am using CPLEX to solve linear programming with 3 diferent algorithms.
1-primal Simplex 2-Dual Simplex 3-Barrier Method.
When I am trying to use Barrier method, my clock does not give me a right processing time. I don't have any problem with the other two methods. The value I am getting from ticks2 is 0 when I am using Barrier solver unlike the two other methods that I am getting some small values (ticks1 is fine). Using time_t ticks1 , ticks2 and time(&ticks1) and finally difftime(ticks1,ticks2) also gives me an integer number which is not precise enough. I need a way to compute cputime with accuracy of at least 2 decimals.
clock_t ticks1,ticks2; double solvingtime if (solver.primopt==1){ ticks1=clock(); status=CPXprimopt(myEnv, myLP); ticks2=clock();
Code: void Plot(int nx, int ny, double x[350], double y[350], double C_new[350][350], int iplot){ int i, j; char fname[50]; FILE *fp;
[Code]....
I am then taking the generated file and importing it into a plotting program (Techplot360). It would speed up the importing process if I created a binary file instead of a like above. I know that I need to use fwrite but I am unsure how to handle lines like
Code: fprintf(fp, "TITLE= ABCDEFG_%d ", iplot); and
I'm currently working on a program that writes an array of struct to a file and then read back the data from the file to another array of struct. At the bottom is an image of my result.
My goal is to end up with two identical struct arrays but my program fails to do this. My struct have to members: ID and kind (of animals in this case). I declare my first arraystruct africa[] with "monkey" and "giraffe" with their respectively IDnr: 112 and 555. I stream this data to a file and read read them back to the arraystruct get_animal[]. Simply I want the get_animal[] to be identical with the africa[] when the program is over, but that is not so. According to my result(bottom image) it display:
112, monkey (get_animal[0]) 112, monkey (get_animal[1]) meaning that get_animal[0] is identical to africa[0] get_animal[1] is also identical to africa[0]
but why? I want get_animal[1] to be identical with africa[1]. meaning I want the result to look like this:
112, monkey 555, giraffe
I've also made the program to print the parameters of my fwrite/fread calls. Why is the 3rd parameter = 1 meaning that only 1 element will be read/written when my program just read/write 2 elements?
union { short *two_int; int *four_int; double *eight_real; char *one_ascii; // void *v; };
We have write function which write into file.
fwrite (r.one_ascii, 1, i, outstr);
I found one thing,When we write function, we fill only four int in following way.
r.four_int[0] = x + xoff; r.four_int[1] = y + yoff;
So my question,we fill four_int but write one_ascii only.As is it union of pointer. So it does not matter. I am using 64bit machine and do not have any issue in 32 bit machine.
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() {
[Code]....
this code asks the user to input words/strings until he enters "end."after that, the program must copy the input to a text file named read.txt...I entered 'j' and then 'end' and after that I looked at the read.txt file and here's what's in it.
Output:
Code: j ; end
some weird characters appeared!! the characters in the text file should only be.
I am trying to write a function to reverse a wav file. The idea is to copy the header as it is from the begening of the input.wav file to the beginning of the output.wav file. After that i have to take count number of bytes(count = numberChannels * bitsPerSample in the wav i use this is 2*16= 32 bits, 32/8 = 4 bytes). With this code i am trying to copy the header( that's working fine) and then copy 10 samples from the end and put them to the output.wav file(after header not at the beginning).
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;
I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly. I can't find anything wrong.
Code:
#include <iostream>#include <iomanip> #include <string> #include <fstream> #include <cmath> usingnamespacestd; int main ()
Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.
Code: #include <stdio.h> int day, month, year, next_day, next_month, next_year, calculation; int main() { printf("Enter a date in the form day/month/year: "); scanf("%d %d %d", &day, &month, &year);
As part of a project i want to display the speed of a small wheel on a 7 segment display. I am using a hall effect sensor to pick up the pulses of the rotation. I am not sure how to write a programe on C to calculate the RPM from this....
I am having trouble with my C++ program. My program asks the user to enter any number greater than 0 and less than 20, and if the user enters any number(s) outside the acceptable range, the output should display:
input outside of exceptable range > 0 and < 20 length: 1 width: 1 area: 1 perimeter: 1
But in my program, this output displays no matter what the user types (even if the numbers are in the acceptable range, when it should be displaying the length and width the user enters and also displaying the calculated perimeter and area whenever the user enters number(s) in the acceptable range. Here is my code:
I am just learning arrays, I modified my program to use arrays but now it wont calculate the gross pay well it seems it does but not correctly. The gross pay is coming back as "-9.25596e+061" it worked fine before I added arrays. I do have a text file with the following input :
John Doe 1404 45 20 H Bobby Jill 1404 45 20 S
#include <iostream>//including library (directive header file) #include <windows.h>//makes console look pretty #include <fstream>//Library to read files #include <iomanip> using namespace std; int main() { SetConsoleTitleW(L"Payroll System");//Set Console Title
Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The data in the output file will be nearly the same as the data in the input file except that you will print the names as last_name, first_name and there will be one additional number at the end of each line: the average of the student's ten quiz scores.
The output file must be formatted such that first and last names appear together in a left justified column that is 20 characters wide where the last name comes first, then a comma and a space and then the first name. Use your read string function to read each name separately and then put them together into a larger correctly formatted string before trying to output them. Each quiz score should be listed in a right justified column that is 4 characters wide, and the average should appear in its own right justified column that is 10 characters wide.
Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10; these students are assumed to have missed one or more of the quizzes. The output file should contain a line (or lines) at the beginning of the file providing appropriate column headings.
my code is working as expected except a slight error, i have to find min max and median values of an inputed array terminated by 0, the problem im having is with calculating the minimum, where when i enter 0 to terminate the program it uses 0 as the minimum value. my code is as follows
I wrote a function to calculate the hypotenuse of a triangle. My code looks fine but when i enter the two sides it does not give out the right answer. I really don't know what to do.
When I compile my code with g++ I get the error: constructor, destructure or type conversion missing before sum.
int sum(int,int); void sum(int,int,int&); main() sum (v) // This is the line that the compiler is reporting the error occurs. answer sum() int main(){ int a=1; int b=2; int sum;