Sponsored Content
Homework and Emergencies Homework & Coursework Questions C++ inputting multiple strings Post 302363470 by jp2542a on Tuesday 20th of October 2009 11:06:20 AM
Old 10-20-2009
Quick and dirty hint:


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

struct student {
	char name[80];
	int mark;
} grade[20];


int main ()
{

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

 

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
FBB::Ranger(3bobcat)						   Error handler					      FBB::Ranger(3bobcat)

NAME
FBB::Ranger - generalizes ranges for range-based for-loops SYNOPSIS
#include <bobcat/ranger> DESCRIPTION
The Ranger class template defines ranges that can be used with range-based for-loops. The standard range-based for-loop requires for its range-specificiation an array or an iterator range as offered by, e.g., containers (through their begin and end members. Ranges defined by a pair of pointers or by a subrange defined by iterator expressions cannot currently be used in combination with range-based for-loops. Ranger extends the applicability of range-based for-loops by turning pairs of pointers, an initial pointer and a pointer count, or a pair of iterators into a range that can be used by range-based for-loops. Ranger is a class template requiring one template type parameter: Iterator, an iterator or pointer type reaching the data when derefer- enced. Ranger's users don't have to specify Ranger's template type. The function template ranger returns the appropriate Ranger object. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. FREE FUNCTION
When using the following free functions, any (subrange) of iterators or pointers can be used. With iterators subranges of reverse iterators can also be specified. The EXAMPLE section below illustrates the use of the ranger function templates. o Ranger<Iterator> ranger(Iterator &&begin, Iterator &&end): this function template returns a Ranger object for the (sub)range defined by two (reverse) iterators; o Ranger<Iterator> ranger(Iterator &&begin, size_t count): this function template returns a Ranger object for the (sub)range defined by the (reverse) iterator range begin and begin + count; o Ranger<Data *> ranger(Data *begin, Data *end): this function template returns a Ranger object for the (sub)range defined by the two pointers begin and end; o Ranger<Data *> ranger(Data *begin, size_t count): this function template returns a Ranger object for the (sub)range defined by the two pointers begin and begin + count. CONSTRUCTORS
Below, Iterator refers to the Ranger class template's type parameter. Although named 'Iterator' it can also be a pointer to some data type (e.g., std::string *). o Ranger(Iterator const &begin, Iterator const &end): A Ranger object can be passed as range-specifier in a range-based for-loop. All elements defined by the range will subsequently be visited by the range-based for-loop. The copy and move constructors are available. OVERLOADED OPERATORS
The copy and move assignment operators are available. MEMBER FUNCTIONS
o Iterator const &begin() const: returns (a copy of) the begin iterator passed to the Ranger's constructor. Note that if Iterator was a pointer type (like int *) the data to which the iterator returned by begin() can actually be modified, as the member's return type (using int * for Iterator) becomes int * const &, so a reference to a constant pointer to an int. This is perfectly OK: if the data themselves should be immutable, then the data type must be defined as int const, which is automatically the case when passing int const * data. See the EXAMPLE section for an illustration. o Iterator const &end() const: returns (a copy of) the end iterator passed to the Ranger's constructor. If reverse iterators are passed to Ranger's constructor, then the begin and end members return reverse iterators. Since the intended use of Ranger objects is to define a range for range-base for-loops, members like rbegin and rend can be omitted from Ranger. EXAMPLE
#include <vector> #include <iostream> #include <bobcat/ranger> using namespace std; using namespace FBB; int main() { vector<int> iv {1, 2, 3, 4, 5}; // display and modify a subrange for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el++ << ' '; cout << ' '; // display a reversed range for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el << ' '; cout << ' '; // same: display using a count for(auto &el: ranger(iv.rbegin() + 1, 3)) cout << el << ' '; cout << ' '; int intArray[] = {1, 2, 3, 4, 5}; // display and modify elements // in a pointer-based range for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el++ << ' '; cout << ' '; // data now modified for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el << ' '; cout << ' '; // using a count rather than an // end-pointer for(auto &el: ranger(intArray + 1, 3)) cout << el << ' '; cout << ' '; int const constInts[] = {1, 2, 3, 4, 5}; // data can't be modified for(auto &el: ranger(constInts + 1, constInts + 3)) cout << el << ' '; cout << ' '; } FILES
bobcat/ranger - defines the class interface SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::Ranger(3bobcat)
All times are GMT -4. The time now is 01:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy