green_leav 6 Newbie Poster

questions
1-: why do i have to put cin.ignore(); ?

2- this is the function for opening files :

void Tran(tempt a[], int b)
{
	string *file=new string[b];	
	ofstream *outfile=new ofstream [b];
	cout<<"The names of the files are: "<<endl;
	for (int i=0;i<b;i++)
	{
		file[i]="C:\\My resieved files\\"+a[i].name.first+"_"+a[i].name.last+".xls";
		outfile[i].open(file[i].c_str());
		while (!outfile[i])
		{
			cout<<"ERR"<<endl;
			exit(1);
		}
		cout<<"File number "<<i+1<<" name is: "<<file[i]<<endl;
		outfile[i]<<"first name\t"<<"last name\t"<<"ID\t"<<"telephone\t"<<"Address\t"<<"Gr1\t"<<"Gr2\t";
		outfile[i]<<"Gr3\t"<<"Gr4\t"<<"Gr5\t"<<endl;
		outfile[i] << a[i].name.first <<"\t";
		outfile[i] << a[i].name.last <<"\t";
		outfile[i] << a[i].id << "\t";
		outfile[i] << a[i].tel << "\t";
		outfile[i] << a[i].add<<"\t";
		for(int j=0; j<5; j++)
			outfile[i]<< a[i].grade[j]<<"\t";
		outfile[i]<<endl;
		outfile[i].close();
	}

}

is it right?

3- why did you tell me that i have to do file.clear(); ?
i want to keep the files not to erease them?

green_leav 6 Newbie Poster

when i write getline (cin,stdrec.add)<<endl; and execute the program it passes through it without allowing me to write things in the address
why is this happening?

green_leav 6 Newbie Poster

it didn't work with me when i use either getline or cin.get

green_leav 6 Newbie Poster

the program has just made one file which is the first file and then couldn't make the other files
could you give me another solution?

green_leav 6 Newbie Poster

when i did it, the program couldn't open the file and said ERR as i told him
what should i do?

green_leav 6 Newbie Poster

I almost finish the code but i still have a problem in opening more than one file in one code

this is my code:

# include <iostream>
# include <sstream>
# include <string>
# include <fstream>
#include <iomanip>
using namespace std;

struct nameType
{
	string first;
	string last;
};
struct tempt
{
	nameType name;
	int id;
	int tel;
	string add;
	int grade[5];
};
void readKeb (tempt stdrec[], int x);
void copyFile (tempt a[], int x);
void Search (tempt stdrec[], int x);
int Search_ID (tempt stdrec[], int x, int ID);
int Search_Name (tempt stdrec[], int x, string First, string Last);
void Generate (tempt stdrec[], int x, int answer);
void add ( tempt stdrec[], int x,tempt stdfile[],int &a);
void sort1 (tempt stdrec[], int x);
void swap (tempt & a, tempt & b);
void readFile(tempt a[],int &b);
void Tran(tempt a[], int b);

int main()
{
	int x,a,b, z=0,v,n;
	cout << "Enter the number of students: ";
	cin >> x;
	tempt *stdrec = new tempt[x];

	readKeb (stdrec, x);
	copyFile (stdrec, x);
	cout<<"To search for a student press 1: "<<endl;
	cout<<"To pass this request press 0: "<<endl;
	cin>>v;
	if (v==1)
		Search (stdrec, x);
	/*Tran (stdrec, z);*/
	cout<<"If you want to add new students press 1, to choose another thing press 0: "<<endl;
	cin>>v;
	switch (v)
	{
	case 1 :
		{
			cout << "Enter the number of new students you want to add :  ";
			cin >> b;
			a=x+b;
			tempt *stdfile = new tempt [a];
			add ( stdrec, x,stdfile,a);
			break;
		}
	case 0:
		{ …
green_leav 6 Newbie Poster

well.......i didn't take (delete) yet..... if you have time could you explain to me the last steps in the code?

green_leav 6 Newbie Poster

Thanks for the information but i actually done the second type of array because i'm still studying the basics of c++.
I didn't understand how can i delete the old information in the array and to input other data again, if u could provide an example to me or repeat the explanation in a simpler way i will be very pleased

sorry for annoying

green_leav 6 Newbie Poster

Hello everyone....this time a have a competition program that I want ur help but this time i just want from u answers to some problems that i faced when i was working on it :

this is the program:

Mail merge is a software function describing the production of multiple (and potentially
large numbers of) documents from a single template form and a structured data source.
This helps to create personalized letters and pre-addressed envelopes or mailing labels for
mass mailings from a word processing document which contains fixed text, which will be
the same in each output document, and variables, which act as placeholders that are
replaced by text from the data source. The data source is typically a spreadsheet or a
database which has a field or column matching each variable in the template. When the
mail merge is run, the word processing system creates an output document for each row
in the database, using the fixed text exactly as it appears in the template, but substituting
the data variables in the template with the values from the matching columns.
This technique of merging data to create mailshots gave rise to the term mail merge.
As a part of the competition that will take place at the end of February, you have to
implement the mail merge software that is able to:
1. Read the students’ records and saves them to a file.

Fbody commented: starting an identical thread when the first one doesn't work is not cool +0
WaltP commented: With the plethora of double posts lately this was obviously a DaniWeb glitch +9
green_leav 6 Newbie Poster

Hello everyone....this time a have a competition program that I want ur help but this time i just want from u answers to some problems that i faced when i was working on it :

this is the program:

Mail merge is a software function describing the production of multiple (and potentially
large numbers of) documents from a single template form and a structured data source.
This helps to create personalized letters and pre-addressed envelopes or mailing labels for
mass mailings from a word processing document which contains fixed text, which will be
the same in each output document, and variables, which act as placeholders that are
replaced by text from the data source. The data source is typically a spreadsheet or a
database which has a field or column matching each variable in the template. When the
mail merge is run, the word processing system creates an output document for each row
in the database, using the fixed text exactly as it appears in the template, but substituting
the data variables in the template with the values from the matching columns.
This technique of merging data to create mailshots gave rise to the term mail merge.
As a part of the competition that will take place at the end of February, you have to
implement the mail merge software that is able to:
1. Read the students’ records and saves them to a file.

green_leav 6 Newbie Poster

thank u very much and sorry if iam annoying u with my assignment

ill work it and see what is missing and will tell u the results

bye

green_leav 6 Newbie Poster

well....yes i need a help in the last point first of all how can i access this comand
char unlocking_word [] = "GREEN"; ?
the user will enter GREEN and this is an array with empty number of components is it ok?
second thing is : how can i check if the user entered all the letters in uppercase not in lowercase?

third thing is : i want to use sorting in order to make the unlocking word letters at the begining of each ring but how? I didnt understand the way u write it how can i save the green chars in a temp then puting them?

i know that iam annoying u but i really have difficulties in c++ and this assignment must be done on sunday but could u write a simple example of this code in order to understand it more?

thank u for every thing

green_leav 6 Newbie Poster

dear GrubSchumi,

first of all the user will enter the number of test cases (2) then the number of rings (5) and next the unlocking word which is GREEN and finally the secret word _P___ but my problem is how can i let the program find the rest of the secret word lettes? and how can i get a help from the unlocking word?

green_leav 6 Newbie Poster

hello members...........i need a help from someone to give me an idea of how can i write a code for cryptex

i have an assignment and i couldn't figure out how to start writing a code


i just need an idea of how the program will work in order to write the code


please reply to me as soon as u can before sunday 27th of december

the assignment is :

Question 1: This question is taken from the ACM programming competition.
Leonardo Da Vinci, the famous inventor and artist, was fond of cryptography and has
invented many devices and techniques to hide messages. One such invention is the
cryptex. A cryptex is a small device used to carry a secret message and is made of one
or more rings. Each ring has the 26 uppercase letters written in some random order. It
is by aligning these rings in one specific way that the secret message is revealed. The
secret message is made of two words, each of length N. The first word of the secret
message is called the unlocking word and the second is called the secret word. To
properly align the cryptex, you need to know the unlocking word. Once you have the
cryptex and the unlocking word, all you have to do is align the rings on the cryptex to
spell the unlocking word. The letters on …

Salem commented: Bye, you just dumped your assignment in a word doc, and made no effort. -3
green_leav 6 Newbie Poster

this is my code

#include <iostream>
using namespace std;
int i,n; 

int main()
{
    cout<<"Welcome to c++ program"<<endl;

    for (n=1;n<=1000;n++)
    {
        for (i=2;i<=n-1;i++)
        {
            if (n%i==0)
                break;
            else
                cout<<n<<endl;
        }
    }
    return 0;
}

can u correct it for me?

green_leav 6 Newbie Poster

well.............i m trying until now....................i solved questions one, two and three but im now stucked in question...........my code is repeating the prime numbers alot not just once ......................please can u help me

green_leav 6 Newbie Poster

please i need help in my c++ assignment

its about loop ( while and for) and i cant do it

im gonna write it and hoping if any one can solve them before 25\10

pleaaaaaaaaaaaaaaaaaaaaaaaaaaase

1- write a c++ program that will read in the integer N, and calculate:
a) the factorial : N! =N (N-1) (N-2).....(2)(1)

b)the summation : N^2 = )^2 + 1^2 + 2^2 +......N^2

2- Write a program segment that prints the factorials for the numbers o through 7.

3- Write a program that will print all prime numbers between 1 and 1000.

4- write a program that asks the user to enter 5 grades. The program must calculate and print the minimum, the average and the maximum.

5- Write a c++ program that reads x and y then calculate x^y (y is an integer).

6- Read the following problem statement then formulate the algorithm using pseudo code and flowchart.

i have still more but for now please solve these ones