Make a C++ Program that will use nested if else and any looping statement to display the following a certain number of times depending on how many times the user wants it to do so.
Input Values:
1. Name of employee
2. Position in the company
3. No. of hours worked
4. Rate per hour
5. Overtime hours
Required Output:
No. Name Position Rate per No. of hours Basic No. of overtime Overtime
hour worked Pay hours Pay
1. Juan Manager 160 140 22400 10 2100
Computations:
basic pay = no. hours worked x rate per hour
overtime = overtime hours x 150% of rate per hour
Just asking how can I input the name, position, rate per hour, overtime hours and hours worked in a horizontal manner?
Because I need to achieve the required output.
I need to write a ANSI program to print out each command line argument on a separate line using a for-loop. also it need to print the name of the executable .so far I have
Code:
#include <stdio.h> int main(int argc, char **argv) { int i; printf("")
l need to write a program which writes out its command line arguments in reverse order one per line. The output from the program should look like this:
% a.out Two roads diverged in a yellow wood wood yellow a in diverged roads Two
I am trying to read a file line by line and then do something with the informations, so my method looks like this:
Code: void open_file(char *link) { FILE *file = fopen(link, "r"); if (file == NULL) { fprintf(stderr, "Could not open file. "); exit(EXIT_FAILURE);
[Code] ....
1) The first complain of valgrind is at the line where I use fgets and its telling me (invalid write of size x), but I have allocated my line to 56000 and the read line is shorter, why is there a write size error then :S?
2) at the line where I realloc where I try to shrink the space he's telling me: Address .... is 0 bytes inside a block of size 56000, But I know i need only this space so why is there a write over space error :S??
I need to read lines from one file and copy them line by line into another file using dynamic memory allocation. It compiles but gives me a seg fault. Why/How?
There are numbers of lines connected to each other. I've extracted the line start point and end points but i am confused how to compare the end point of one line with the start point of adjoining line.
I'm using fgets which will read a single line at a time, but unlike fgets I don't want it to return the new line char ( ) ?I want to be able to use printf to display the lines next to each other.
I need to read a text file which has various lines containing integers. I need to write those integers separately in a vector. Example, the first line of the text file contains 3 9 8 7 6 so vector[4]=3, vector[3]=9, vector[2]=8 and so on. Next read the second line 4 1 2 3 4 5 and write to another vector vector[5]=4, vector[4]=1...
I tried the code below but it will write from the second line, the whole line in one vector index.
int str; // Temp string to cout << "Read from a file!" << endl; ifstream fin("functions.txt"); // Open it up! string line; // read line count from file; assuming it's the first line getline( fin, line );
As, it can be seen from the above structure that whitespaces are not same everytime. So, to deal with this situation, i am using boost library to remove all whitespaces from the line which is being read and then try to find the name of gate and its input. My code is given below which is able to correctly find the gate names and its first input...but my code is not able to find the second, third and so on input names.
How to read a file line by line and then later access them by doing something like
Code: lines[0] //Line number one ... lines[100] //Line number one hundred and one lines[100][0] //L lines[100][1] //i lines[100][2] //n lines[100][3] //e lines[100][4] // lines[100][5] //n ...
Just working up for the google coding contest to start soon and have been practising some of the test questions however i make correct algorithms but my output is rejected because of the fact that my strings are printed on a new line so i wish to know a method to print strings using a printf statement or any other function on the same line ...
I write a program which now works perfectly well. However, I want to make it run at the right time automatically, instead of waiting for a user to start it when needed.
The basic problem is, that in a WinPE environment an exe is running. Unfortunately it would need critical input, which must be inputted perfectly. So, I wrote a program which gets the data and sends it to the other app, by bringing it to the front and presses the keys needed using SendInput().
However, this program should wait for it's cue, then get on the inputting part. It's cue should be the point where the program waits for the first user input with this displayed on the last line:
Text:
My question is: how to listen and check whether the last line displayed is "Text:"?
I've tried with AttachConsole(), but for some reason it opens a new console window. I checked and the PID I'm using is the console window's, so I don't know why that happens.
Please don't criticize the first line. I know it can be ambiguous, but I modified it, When actually using it, the exe name will be in the title, so it will be unique.
I have an external file with one column of data. If I have a counter value let say counter =1, and counter++ and so on. How I can write such a c++ code that if the value of counter and value from the external file are same then generate an action let say cout both values i.e. value of counter and value from external file.
for more information, here is an example:
data in file(in one column): 2 6 8 9 10... value of counter : 1 2 3 4 5 6 7 8 9...
then cout values only if value of counter and value from the file is same.
Here is my code so far, but it does not seem to work;
#include<iostream> #include<fstream> using namespace std; int main() { const int SIZE = 10; //Size declaration of array int hours[SIZE]; //Array declaration
I am reading my file (20GB) line by line using boost like this
PHP Code:
boost::interprocess::file_mapping* fm = new boost::interprocess::file_mapping("E:Mountain.7z", boost::interprocess::read_only); boost::interprocess::mapped_region* mr = new boost::interprocess::mapped_region(*fm, boost::interprocess::read_only);
Code: #include <stdio.h> int main(){ int A, B; char decision; printf("Do you have an integer to input? [Y/N]: "); scanf("%c",&decision); if(decision=='Y' || decision=='y'){
[Code]....
After entering a single integer, it doesn't scan again for another integer. What's wrong?
I'm using a mac btw, if that makes a difference with Ubuntu/Linux.
I have a dice roller program that I want to use in different program and I know there is a better way to add than copy and paste all of the code, but dont know how. Can I attached it as a file and call the file in my main program?