Programming :: Input And Output On C++ Programming ?
Jan 28, 2010
As i am new to C++ i couldn't figure out how to input a file and make some change on the file and produce a output file. like this problem i have is.
"Program that processes an input file and produces an output file. The input file will contain lines of data, each containing two floating point numbers. The lines of the output file should contain the two numbers read and their average (with a '$' sign and 2 places after the decimal point)."
View 2 Replies
ADVERTISEMENT
Aug 14, 2010
I am creating a 15 integer array which is input from the user and outputted for the.
Ex.
Enter the array values: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Your values are: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Code:
View 4 Replies
View Related
Sep 7, 2010
While making a shell ,there is the following problem Im facing:
I am expecting the user to enter commands in the following format :
I am to separate these and the output of ls -l should be given as input to grep and the output of both to more.
But I am allowed (by our instructor) to use dup/dup2 or any other command(but not pipe or tees).
How to connect the file descriptors after successful execution of each command?
View 5 Replies
View Related
Nov 12, 2009
I am not sure if that Subject really explains it, basically I have a script that executes a CLI java-applet that requires a passphrase from the user. I can easily execute this by issuing the -p argument followed by the passphrase however that shows up on possible logs or at least on the results of the ' ps ' command. If you do not supply this -p argument it provides a new line with the echo " Enter Passphrase: " and asks for input.
how can I provide a result/input for the Passphrase request and is it still possible to throw this application in the background with the ' & ' following the command? I have seen a few examples that show a /bin/expect that expects a result and sends a command however I would like to refrain from any extra dependencies. Example of Regular Execution of application:
Code:
$ /usr/local/***/**** -u USERNAME -r Default-Realm -f certificate.der
Password:
View 6 Replies
View Related
Jul 13, 2011
Dear advanced c/g++ programers:A program request me to enter twice inputthat program probably is tested good on visual c++ 7.1 on window xp,but my system is g++ on linux(Ubuntu10.04)
It assume
Enter some strings: a b c d
^Z
[code]....
View 1 Replies
View Related
Jan 21, 2011
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
Do i have to use sed command?
View 4 Replies
View Related
Apr 1, 2010
I've done a little program, it's the snake game. I use an X window to show the snake and all that but the input is taken from the terminal. That means that what I have to do to play the game is open it with the terminal and then the game opens but then I have to go to the terminal again to move the snake. if I open the game from the GUI I can't do anything because it doesn't take my directions. What do I have to do in order to get the program to have a connection with my keyboard? I use getchar() to get the input, maybe there is something else?
View 9 Replies
View Related
May 2, 2011
I'm trying to make a program to simulate a parabolic movement, so i've added 2 entries, one for the initial velocity and other for the angle, anyway you probably don't care about that xD what i want is to take the number entered in the entry and put it in a variable to do the math, and then show everything in a dialog or something. how do i do that?
View 3 Replies
View Related
Jun 19, 2010
Does diff not like arrays? How do achieve the following?
Code:
stuart@stuart:~/music transfer$ diff file1.txt file2.txt
1c1
< bonkers_in_phoenix.mp3
[code]....
View 14 Replies
View Related
Jan 18, 2010
what i am trying to do is to allow the user to key in data such as "23.23" or "24" , as it is the price of certain objectsHow am i able to design a check which will allow me to prevent users from typing in input such as "ab.21" or "rfrr" as this field is purely a numerical field. The problem i am facing is i tried using this search code.
Code:
echo "read this"
read this
[code]....
View 14 Replies
View Related
Feb 2, 2011
right now i am writing bash script for simple everyday todo tasks.script consisit of two files, fisrt is just script (which can delete/append /clear) and second one is todolist.txt which stores my notes.I am litlebit confused about sed!!for example, If my todolist.txt have these lines:
- Writing my Homework
- take my girlfriend to launch
- Take a break
How can sed take my input $@ and delete all line with name "Homework"..i trayed with many sed combination like:
Code:
sed s/$@//g
sed 'd/$@/'
and many more combination with ""/'' or bracket but nothing helped
View 5 Replies
View Related
Jun 10, 2013
I need a way to use serial input such as through an Arduino in Debian scripts, in any usable language.
View 2 Replies
View Related
Apr 28, 2010
I've written a bash script that allows a user to input a directory location to find out the size of the directory. However, if the user inputs a directory and finds its size then inputs another directory then wants to quit, the script asks the user numerous times if he wants to quit!! The script won't exit until the number of times the user looks at a directory is reached! What gives?
Here's the script:
Code:
View 4 Replies
View Related
Jan 4, 2010
I am trying to learn C++.I implemented a simple archive program, and I am in a situation in which the user is prompted by a menu to make a choice.So I have some cout instruction to illustrate the possible choices and then
int choice;
cin>>choice;
and everything works fine.I introduced this code in a "while" loop that checks wether the choice made by the user is valid or not:
bool check=true;
int choice;
while(check)
{
cin>>choice;
if(the choice is valid) {...;check=false}
else cout<<"please make an other choice"
}
What is happening is that if by mistake the user introduces a character in place of a number, the loop repeats indefinitely because the program, when it get to the "cin" instruction, does not pauses to wait for a new input.
View 7 Replies
View Related
Mar 19, 2010
I would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).
Some samples:
char *mychar= "a3547"; (The result of function checking this is true)
char *another_char = "t6548"; (The result of function checking this is true)
char *next_char = "appl3"; (The result of function checking this is false)
char *new_char = "b1aa3"; (The result of function checking this is false)
View 4 Replies
View Related
Aug 5, 2010
Write a program that requires the user to input the name of a file as an argument. If the user fails to include one argument it should make use of a thread that handles a signal. The signal handler should tells the user Incorrect number of arguments and then calls the terminate signal on the process.
If the numbers of arguments are correct then the program should allocate memory space to the file (5MB) and create a child process that requests the user for a character that it should send to the parent. The child should keep request for data until the user keys in the character O. During each request it should pause for 10 seconds, send the character to the parent and then requesting again for another character.
The parent should get the character from the child. Do not make the parent wait for the child to finish requesting for data. Make use of pipes to facilitate communication between the parent and the child. A second child should be created to read and display data from the file. Make use of any appropriate Inter Process Communication technique to ensure that the second child and the parent do not access the file simultaneously (Mutual exclusion).
View 5 Replies
View Related
Apr 11, 2010
i have to write a program which checks the information inside a text file to make sure it is all integers and then convert the integers to roman Numerals. My program seems to have a bit of a problem and im not sure where exactly the problem is....
Code:
#include<stdlib.h>
#include<string>
[code]....
View 8 Replies
View Related
Apr 13, 2011
I started to run a C++ my program in Linux and I don't know how to test my program that works fine with a text file. This is a project for my uni and to explain more clear, My program is a sample database for modify or add and search and it read data from a binary file and also write into a binary file. I have got an input from my lecture and she said after compiling in Linux I must write:
1-to compile:
Code:
g++ (files with cpp)
2-to see the output:
Code:
./a.out
3-to test with input:
Code:
./a.out < input.txt >
My problem is in step three. What I must write in the command part after" step2" to see the output?
View 3 Replies
View Related
Jan 25, 2011
I have a C program that may finish in seconds or weeks depending on the data. For the longer jobs I want to be able to press a key and get an intermediate result printed.
View 14 Replies
View Related
Apr 26, 2010
I have this piece of code in my shell script file:
Code:
useradd $UserName; passwd <& $password
I am not able to perform Input Redirection while setting password programatically- without any user intervention.
I think there is a way to do it, but it is just getting slipped from my mind at the moment.
View 2 Replies
View Related
May 23, 2011
I want to select the branch based on the INPUT. Here is the program segment which uses the case statement.
case $INPUT in
1)branch="Computer Science";;
2)branch ="Electrical";;
3)branch = "Mechanical";;
4)branch= "Aerospace";;
esac
When I run this script, I am getting an error, Electrical command not found?
View 2 Replies
View Related
Jun 21, 2011
I'm writing a program which now accepts user input:
Code:
echo "Enter a date in the format YYYY MM DD hh mm ss."
read gregyr gregmo gregdy greghr gregmn gregsc This lets the user input a date and time, such as 2011 06 21 15 12 45, and have each number assigned to their corresponding variable. Later in the program, these variables are put into an equation, and then the terminal spits out the answer. Now I have to have the program read all of the lines from a text file, which is in this format, assign the variables.
View 7 Replies
View Related
May 7, 2010
As I'm starting to learn bash scripting I'm trying to automatize some tasks I usually perform. I have a notification mail I need to send several times a day. It has this structure:
Quote:
Dear user,
blah blah blah blah
You need to contact the following people:
[code]...
To replace "user", I found this:
Code:
read -p "Please enter username: " username
echo "Dear $username,"
Which probe to be very useful with other simple notifications like this. But I don't know how to manage the email addresses as they are usually more than one and could vary from 1 to 10. They should appear one above the other. I found this: "Here is a little work around. The only thing the user needs to do is hit enter without anything else on a line and it will close out"
Code:
#!/usr/bin/ksh
word=a
until [[ $word = "" ]];do
[code]....
I tried to use it and modify for my needs but I failed, I don't realize yet how can I use it. If possible, I would like to use the until loop like the above example just for learning purposes but any other form will be accepted as well.
View 10 Replies
View Related
Jun 17, 2011
Sed seems to react to the presence of "" in its input if the immediately following character makes the pair a recognizable code. In the code following see that the "a" and "" are missing in the output, and that the "c" caused sed to terminate at that point. Is there any way to prevent it reacting like this?
Code:
g y="the shell built-in command. The following character sequences
> have special meaning:
> a Alert (bell).
> Backspace.
>
> c Suppress trailing newline.
> f Form feed.
>
[Code]....
View 3 Replies
View Related
Jun 2, 2009
I've been using python/bash to help myself automate things for a long time, however I am curious. One reason I use python more is because I don't quite know how to work with user input in Bash, such as getting it to ask for input and wait, and then placing that user input into a command.
Here's an example of a script I use from time to time for converting OGG video files into AVI.
How could I write this same script in Bash? Keep in mind I am mostly self taught, so I am by no means an expert programmer.
Code:
View 3 Replies
View Related
Oct 27, 2010
If I have an array which its size is based on the user input, from some material, I need to use malloc function to allocate memory for that array what is known dynamic array. Don't forget to free it.hat's fine, however, I like to try things out even I know the program will crash.I have written some test program on my Mac using C language like this:int width = 0;//get user input, and assign the input value to width, for example, 3char * array_var[width];and width is an int, its value will be assigned by the user input. The point is, this program work as expected, for example, in command line, I input 3, then array_var length is 3, its size is 3 * sizeof(char *).
View 1 Replies
View Related
Jan 20, 2009
I have this little shell script which copies file names taken from inputfile:
Code:
while read line; do
cp -i $line something
[code]...
View 4 Replies
View Related
Aug 9, 2009
I have a script im having some problems with, what I need is to have the system generate a random password for me and use that password when creating new users to it.
System is Debian Lenny and script is in bash.
The program is znc. I have made it so that it will generate the random password on the shell but the problem is to use it in the bnc software.
To make a password there the command is znc --makepass and look like this:
My question is now if it would be possible to put in the script so it would "answer" when it need those passwords ? the random password that is generated is in a variable called $setpass and is NOT crypted.
Or is there any other software that would be able to generate that md5 string for me ?
View 7 Replies
View Related
Mar 5, 2010
I am trying to write an irc bot to run interactive fiction games in a channel. I am connecting to the channel using nc. I'm having a hell of a time trying to supply input stdin for nc after the connection is established. Here's what's going on. I've got lines of plain text in a file with the irc commands required to identify the bot's ID and join the channel. I can connect easily using any of the following commands
cat inputfile | nc irc.servername.org 6667 -i 1
nc irc.servername.org 6667 -i 1 < inputfile
Named_Pipe | nc irc.servername.org 6667 -i 1
cat inputfile > Named_Pipe
With the first two commands nc connects, reads the file with some time between each line allowing the irc server to respond, bringing me into the channel. It then begins to receive stdin from the command line allowing me to do things like "privmsg #channelname :Hello World!!!" sending messages to the room. This is not the desired behavior. I require nc to take additional stdin from the inputfile if I cat additional text to the end of it.
The last set of commands using the named pipe seem like it does the same, but it doesn't actually send anything to the room, which indicates to me that perhaps nc is continuing to take stdin from the named pipe (this is the desired behavior) rather than dropping to the console for stdin. If I try to cat more plain text data to the end of the named pipe, however, either with something like "echo 'privmsg #channelname :Hello World!!!' > Named_Pipe" (or >> instead of >) or with a filename in place of the "echo" command the whole command simply seems to hang until I press ctrl-C.
I don't understand what I'm doing wrong. With anonymous and named pipes, and with redirection, the problem seems to be the same. nc seems to take it's stdin from the file until it hits the end of file, at which point I can no longer introduce new lines of plain text as stdin for the running nc process.
View 4 Replies
View Related
May 30, 2011
I am trying to make a PHP form where the user inputs a text string, and then it is stored in MYSQL db
1.php
Code:
<form action="2.php" method="post">
Your name: <input type="text" name="txt_name" />
<input type="submit" />
</form>
[Code]....
View 1 Replies
View Related