I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?
Suppose there is an array of numbers arr[]. Now, i want a function that accepts the input from the user, and return the array for further manipulation.
For example, if the array is arr[5], then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.
so i got this piece of code today having some slight errors with it, how its actually done as i want to know where i have gone wrong here is the code .. Using a for loop to input and output array values
*/ #include <stdio.h> int main(void) { /* Declare an array of integers */ int Grades[5]; int nCount; /* Populate the array */ for(nCount = 0; nCount < 5; nCount++)
Write a program to read in a sequence of characters one by one. Print out the characters in reverse. You should use a char[]. (Remember single quotes are used for char)
For example:
Please enter characters one by one: (Enter 0 to exit) h e l l o 0 You entered: hello. The reverse of that is olleh.
and this is currently my code
#include <iostream> #include <cstdlib> #include <cstdio> #include <ctime> #include <cmath> using namespace std; int main() { char entry[20];
[code]....
im just not sure how to set that value and still make the for loops work
I have this code that im stuck on what i need to do is Extend the code such that when it starts the user is asked to input values to specify each of the three ranges before moving on to accept and tally the main values how do i do that Using a for loop to input and output array values Also calculate the average
*/ #include <stdio.h> int main(void) { /* Declare an array of integers */ int Grades[5]; int nCount; int nTotal = 0; /* Declare and initialise the value */ float fAverage;
I have written a C++ program I have multiple of CSV file used as input, which I open one at a time and close it after extracting data to a output file which is the only file.
I run getline(inFile,line); outFile << line << endl;
I run this code, and only part of it is goes to the output file I got, also have spacing randomly to specific file and inconsistent
But when I slower the code, like system("Pause") in the loop, I can get extract what I want perfectly....
Is my program running to fast, why getline would be skipping part of what things I want?
How to output vector contents using the push_back function. My program reads in values just fine, but it does not output anything and I've been stuck on why.
here is my code:
#include <iostream> #include <array> #include <vector> using namespace std; int duplicate( vector < int > &vector1, const int value, const int counter)
I would like to, when running cat, send in some data like "testing" to its stdin, and then catch the output of stdout, and put it into a character array variable.Currently the parent stalls till the child is done.I imagine the parent has to some how detect that the child executed 'cat', and then send in input to stdin?Then somehow detect that 'cat' is done executing, and read the output from stdout? I have looked around and found "dup2", but I don't understand how to send in and get data to the child from the parent, especially since the "file descriptors" is not pointing to any files in the first place..
So I have a project in which I am processing audio signals in real-time. I want to create a class to do this using the ASIO driver. I don't want to use a cross platform library nor do I want to use windows API as it is very slow.
I'm trying to write something that when a user is at the command line, the user can type and it displays of list of commands the user can use to run the application.
I have a project, a montly paycheck. So it checks the monthly paycheck of each employees. but my problem there is how to add a new employee when u are a user or in the output of program?
How to structure the input of one .dat file and outputting into another one. I have to loop through a file structured "doe, john, 1500", check for errors and then increase the mp by 50. You also have to do this through using a person class too. I think I need to use a while loop to go to eof and use getline to input correctly, but im not sure how to structure it.
Data file: Horowitz,Jake,1200.24 Flabitz,Bubba,1712.38 Blackwell,Sharon,1872.93 Molerat,Rufus,501.00 Goodall,Jane,1567.43 Sommerset,William,1359.57
for our school project, we have to make a program which involves three students and the prices each of them paid for the meals. The program has to calculate how much each of the students has to pay/receive to/from the others. Most of it, we got from our teacher. The error we are getting is that we have to 'take care of the input/output order'. So if you type in the names/numbers of the students in a different way, so for example if you type first number 1, then 0, then 2 and 0 and 1 have to pay money to number 2, number 0 has to be in front of 1. Our output is that number 1 is in front of number 0.
I'm learning C++. Is there some way to make program function on input from a port like usb port and can I send bits through the port? For example A usb cable connected to a circuit. I press a button and an AND gate on the circuit gets activated by a bit from the usb port and a fan in the room turns on.
I'm trying to write a simple program that will prompt for a string typed in by keyboard and save it to a file. I've tried lots of variations and this is just the latest version.
//Prompt for a string input by keyboard and save it to a file
#include<iostream> #include<fstream> #include <string using namespace std;
Write a program that opens two text files (input1.txt and input2.txt) for input and one for output (output.txt). The program should merge the two input files in the output files. While doing the merge, it will read one line from input1.txt and one line from input2.txt and write those in the output file one after other. Then it will read the next line from input1.txt and next line from input2.txt and write them one after other in the output file.
This is my code:
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { ofstream myproject; myproject.open("input1.txt");
[Code] .....
I need to:
1. how to get the second line in the input1.txt file and so on. 2. After the writing in output.txt, count the number of lines in output.txt. 3. write the number of times term ‘line’ appears in output.txt file.
Alright, so to better myself with network logic I've decided to make a small net game.
I need to input commands to the console as well as output status updates at the same time. I'd prefer to write a gui interface for that, but I'd rather work with WinAPI as little as possible (I mean, look at the way it's designed...).
I'd like to do this with standard operations, limiting dependencies is a must for me.
Ok so This is what the output of the program should be.
enter the count of input integers: 1 The count of the integers must be two or more. Please enter a valid number : 3 Enter integer #1 : 2 Enter integer #2 : -1 Enter integer #3:5
The positive numbers entered and their squares are:
#include <iostream> using namespace std; class Date { private: int month, day, year; public: // class constructors can be overloaded Date(int m, int d, int y) {
[Code] ....
Actually ,I'm not sure whether my understanding of operator>> function is correct. Here is my understanding of operator>> function.....
operator>> function takes Date object as argument from main function and it reads data from the console using istream(This is all I know about istream) into the new Date object which is created by operator>> function..
This is all I know about operator>> function...I really don't know why it has to return istream reference(I know the return type is istream, but other than that ? I want to know why operator>> function creates new Date object ? It already has a reference to Date object ....why not simply set the values of the already existing Date object instead of creating one..?
I'm just starting coding and I just want it to input a date, then output a day of the week.
Code: #include <iostream> #include <cmath> using namespace std; int main() { int startday = 0, sm = 1, sd = 1, sy = 2000, cm = 0, cd = 0, cy = 0; cout << "Please enter the current month, day, and year: ";
I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.
Code: #include <stdio.h> #include <math.h> int main() { int i; int decimaltoconvert; int convertingarray[7]; int convertingarray2[7];
[Code] .....
Also, how might I go about putting that into a function that I could call?
I'm trying to write a program that takes input from the user (thats a char) and outputs it to the monitor in hex form.The program is meant to continuously take input from the user then output to the monitor in hex form until an EOF is detected this triggers the program to close.The following code does this except that I get a lower case 'a' at the end of each output.I think the 'a' has to do with the enter key and if that is the case how can i tell the program to ignore this input from the user.
Example: input from user: ABC output to monitor: 41 42 43 a