Sponsored Content
Homework and Emergencies Homework & Coursework Questions C++ inputting multiple strings Post 302363471 by pondlife on Tuesday 20th of October 2009 11:41:23 AM
Old 10-20-2009
Ooh I thought structs may help but I haven't used them yet - I'll have a play with this and let you know how I get on Smilie

Thanks! Smilie

---------- Post updated at 04:41 PM ---------- Previous update was at 04:09 PM ----------

Sorted! Smilie

Thanks for your help jp2542a!

Here's my final code:

Code:
#include "stdafx.h"
#include <iostream>
#include <string.h>
using namespace std;

struct student {
	char name[80];
	int mark;
	char gradeText[12];
} grade[5];


int main ()
{

	int i;
	
	for (i = 0; i < 5 ; i++)
	{
	
		cout << "Student name (" << i << ") ";
		cin >> grade[i].name;
		cout << "Mark: ";
		cin >> grade[i].mark;

		if ( grade[i].mark <= 100 && grade[i].mark >= 70 )
		{
		
			strcpy(grade[i].gradeText, "Distinction");

		} else if ( grade[i].mark <= 69 && grade[i].mark >= 55 ) {

			strcpy(grade[i].gradeText, "Merit");

		} else if ( grade[i].mark <= 54 && grade[i].mark >= 45 ) {

			strcpy(grade[i].gradeText, "Pass");

		} else {

			strcpy(grade[i].gradeText, "Fail");

		}

	}

	cout << endl;
	cout << "\t\tName\t\tMark\t\tGrade" << endl;
	cout << "\t\t====\t\t====\t\t=====" << endl;

	for (i = 0; i < 5; i++)
	{
	
		cout << "\t\t" << grade[i].name << "\t\t" << grade[i].mark << "\t\t" << grade[i].gradeText << endl;

	}
	
	return 0;
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with inputting password

Hi all, In one of my script, somewhere I need to input password of a server when ssh password's prompt comes. I've tried with EOF but it's not taking. I don't want to disable password through ssh. I want the password should be passed with my script. Any suggestion? Thanks in advance! (2 Replies)
Discussion started by: naw_deepak
2 Replies

2. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

3. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

4. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

5. Programming

Inputting with SPACES...

I can't seem to successfully output characters with spaces. I inputted using getchar(). Any other ideas? Thank you in advance! printf ("Enter the Title : "); int i = 0; int c1; while (( c1!= '\n')&& (i <21)) { new_name->title = c1; i++; ... (0 Replies)
Discussion started by: Nephilim.F
0 Replies

6. UNIX for Dummies Questions & Answers

Inputting info

Hey guys! So I'm working on a program in linux terminal, using perl, to convert dna alignments to amino acid. It involves reading in one sequence and outputting another. I have it set so I can input a file but I can't input any sequences manually, anyone got any ideas about it? I have it set up... (0 Replies)
Discussion started by: PerlNutt
0 Replies

7. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

8. Shell Programming and Scripting

Grep multiple strings in multiple files

Hi, every one! I have a file with multiple strings. file1 ATQRGNE ASQGVKFTE ASSQYRDRGGLET SPEQGARSDE ASSRDFTDT ASSYSGGYE ASSYTRLWNTGE ASQGHNTD PSLGGGNQPQH SLDRDSYNEQF I want to grep each string in hundreds of files in the same directory, further, I want to find out the string... (7 Replies)
Discussion started by: xshang
7 Replies

9. Shell Programming and Scripting

Inputting multiple files into one command

I am trying to read 30 files into a command. The first file contains 10 lines and goes into this part of the command as "x" /tmp/filearrange.sh $x The group of files (20 files, I call them variable $i) need to be the second argument in the command and they need to be read so that they are... (9 Replies)
Discussion started by: newbie2010
9 Replies

10. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies
uucp(1) 						      General Commands Manual							   uucp(1)

NAME
uucp - Unix to Unix copy SYNOPSIS
uucp [ options ] source-file destination-file uucp [ options ] source-file... destination-directory DESCRIPTION
The uucp command copies files between systems. Each file argument is either a pathname on the local machine or is of the form system!path which is interpreted as being on a remote system. In the first form, the contents of the first file are copied to the second. In the sec- ond form, each source file is copied into the destination directory. A file be transferred to or from system2 via system1 by using system1!system2!path. Any pathname that does not begin with / or ~ will be appended to the current directory (unless the -W or --noexpand option is used); this resulting path will not necessarily exist on a remote system. A pathname beginning with a simple ~ starts at the UUCP public directory; a pathname beginning with ~name starts at the home directory of the named user. The ~ is interpreted on the appropriate system. Note that some shells will interpret a simple ~ to the local home directory before uucp sees it; to avoid this the ~ must be quoted. Shell metacharacters ? * [ ] are interpreted on the appropriate system, assuming they are quoted to prevent the shell from interpreting them first. The copy does not take place immediately, but is queued up for the uucico (8) daemon; the daemon is started immediately unless the -r or --nouucico switch is given. In any case, the next time the remote system is called the file(s) will be copied. OPTIONS
The following options may be given to uucp. -c, --nocopy Do not copy local source files to the spool directory. If they are removed before being processed by the uucico (8) daemon, the copy will fail. The files must be readable by the uucico (8) daemon, and by the invoking user. -C, --copy Copy local source files to the spool directory. This is the default. -d, --directories Create all necessary directories when doing the copy. This is the default. -f, --nodirectories If any necessary directories do not exist for the destination path, abort the copy. -R, --recursive If any of the source file names are directories, copy their contents recursively to the destination (which must itself be a direc- tory). -g grade, --grade grade Set the grade of the file transfer command. Jobs of a higher grade are executed first. Grades run 0 ... 9 A ... Z a ... z from high to low. -m, --mail Report completion or failure of the file transfer by mail (1). -n user, --notify user Report completion or failure of the file transfer by mail (1) to the named user on the remote system. -r, --nouucico Do not start uucico (8) daemon immediately; merely queue up the file transfer for later execution. -j, --jobid Print jobid on standard output. The job may be later cancelled by passing the jobid to the -k switch of uustat (1). It is possible for some complex operations to produce more than one jobid, in which case each will be printed on a separate line. For example uucp sys1!~user1/file1 sys2!~user2/file2 ~user3 will generate two separate jobs, one for the system sys1 and one for the system sys2. -W, --noexpand Do not prepend remote relative path names with the current directory. -t, --uuto This option is used by the uuto shell script. It causes uucp to interpret the final argument as system!user. The file(s) are sent to ~/receive/USER/LOCAL on the remote system, where USER is from the final argument and LOCAL is the local UUCP system name. Also, uucp will act as though --notify user were specified. -x type, --debug type Turn on particular debugging types. The following types are recognized: abnormal, chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing. Only abnormal, config, spooldir and execute are meaningful for uucp. Multiple types may be given, separated by commas, and the --debug option may appear multiple times. A number may also be given, which will turn on that many types from the foregoing list; for example, --debug 2 is equivalent to --debug abnormal,chat. -I file, --config file Set configuration file to use. This option may not be available, depending upon how uucp was compiled. -v, --version Report version information and exit. --help Print a help message and exit. SEE ALSO
mail(1), uux(1), uustat(1), uucico(8) BUGS
Some of the options are dependent on the capabilities of the uucico (8) daemon on the remote system. The -n and -m switches do not work when transferring a file from one remote system to another. File modes are not preserved, except for the execute bit. The resulting file is owned by the uucp user. AUTHOR
Ian Lance Taylor <ian@airs.com> Taylor UUCP 1.07 uucp(1)
All times are GMT -4. The time now is 01:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy