Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>print(grid, rows, columns)
Well, where did you declare the variable columns ? You have to declare variables before they can be used or passed as parameters.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think enough of the squabbling from everybody. Thread closed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Good god what is crappy code you posted with has no line breaks ???? I was going to add code tags for you but they would be useless the way that code is formatted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
This	contains a tab
This    contains 4 spaces
But this        contains 8 spaces

Just testing. I used Notepad to create the above text

My suggestion is to change the option in your text editor to convert tabs to spaces because some people might use 8 spaces while others 4 or some other number. I've even seen just 2 spaces.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fstream parameters require const char*, not string. So pass the c_str() method ifstream myfile1 (path1.c_str(), ios::binary) [edit]^^^ what Narue said.[/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>dont you think it will be too lengthy if i do it this way
Yes I do.

>>is there another way to do that...?
Probably several ways. I would (1) define some color numbers

#define BLUE 1
#define GREEN 2
#define RED 3
#define YELLOW 4
// etc for all supported colors

Than set an int color to be one of the above numbers. You could also use enumeration if you know how to use them yet.

Create a structure that contains all the information needed for one user

struct person
{
    std::string name;
    int color;
    // other information here
}

Pass an instance of the above structure to a function whose job is to fill in all the information in the structure. You only write the code once and only in one place -- no need to repeat the same code for every user.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

_cdecl and _stdcall has some difference,.

Yes you are right. .

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thank you very much.
I am working on windows xp machine and IDE is dev c++. Could you please give me some code or example how I will do?

CopyFileEx() link here

Hi
I want to save exe file on client machine.After saving I want to run that exe at client side and want to take result back on server side.

Sorry, don't know the answer to that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

that loop should be written like this:

while (infile >> social >> firstName >> lastName >> gpa)
   {
      currentStudent = new Students(social, firstName, lastName, gpa);
      allInfo[n] = currentStudent;
      n++;
   }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

_stdcall and _cdecl are identical and are the default for C and C++ functions. Therefore is never a reason to use _stdcall or _cdecl in C and C++ programs. Using Microsoft compilers that is. What compiler are you using?

I don't know why its not working for you. Are you sure you have the correct prototype? Do you have the source code for the function so that you can verify -- but you probably already did that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>(NOte: If I remove _stdcall its working fine)
Then what's the problem? Leave _stdcall out then.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>int players[1];
Why is that an array? might as well just declare it as a simple integer instead of an array of 1 element.

>> if(p1color=='R' || 'r')
That's incorrect. Here's the correction: if(p1color=='R' || plcolor=='r')

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what operating system? If MS-Windows you can call win32 api function CopyFile() to copy the file from one computer to the other by specifying the full path including drive letter in the filename parameter.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

add cin.ignore(); after line 21 to clear the keyboard of the '\n' (Enter key). Also read this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> whoever is hanging on to that crap is not likely to shell out much cash for new program >>development on what is probably a maintenance money sink as it is

I know of several manufacturing companies that are still using it on the assembly lines. Why? Because it is a fast little real-time operating system that is ideally suited for such a task. Neither MS-Windows nor *nix are real-time operating systems so they are not suited for receiving and acting upon signals from other equipment (such as barcode scanners, scales, metal detectors, lazer beam etchers, label printers, large character printers, and other computers ) as products move down the assembly line.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No. You are still not reading program requirements very well. Re-read sentence by sentence. Code one sentence then when that is done code the next sentence. I've already mentioned lines 28-33 are wrong.

• Calculate_GPA - This function computes GPA. It does this by looping. It call Get_Letter_Grade to allow the user to enter a valid letter grade and then it calls Convert_Let_to_Num. It uses this information to compute the GPA. It returns the GPA. (you should be able to determine the formal parameters)

Where in the above does it tell you to place the call to Convert_Let_To_Num() in main() at line 30? Answer: it doesn't. Put the damed function call in Calculate_GPA() where the requirements tell you to put it.

One of the qualities of a programmer is the ability to follow instructions by the letter. If you can't do that then just quit and go get a beer (if you are old enough).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sorry....

Next time just hit the Edit This Post button and correct the code tags or whatever else you want to change. No need to repost if you catch mistakes within about 10 minutes.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's a very common programming assignment and you will find a lot of help if you just learn to use google. Links here

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
char choice;
		string subChoice ="";
		getline(cin,subChoice);

		if(subChoice=="100"){
			choice='1';}
		if(subChoice=="200"){
			choice='2';}
		if(subChoice=="300"){
			choice='3';}
		if(subChoice=="400"){
			choice='4';}
		if(subChoice=="500"){
			choice='5';}
		if(subChoice=="E"){
			choice='E';}

Why did you decide to do so much work??? If the integer they enter is not an 'E' then simply divide by 100 to get the values 1-5.

int choice = menu();
if(choice != 'E')
    choice = choice / 100;

The above is a whole lot less confusing then what you tried to do with all those strings.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is still wrong. Verify that you did at lines 28 - 31 with program requirements you posted earlier. You have to read the requirements very very carefully in order to get all the function calls in the correct order.

• Calculate_GPA - This function computes GPA. It does this by looping. It call Get_Letter_Grade to allow the user to enter a valid letter grade and then it calls Convert_Let_to_Num. It uses this information to compute the GPA. It returns the GPA. (you should be able to determine the formal parameters)

line 48: it is not possible to return two variables like that. When the string name is passed by reference you don't have to return it because that's what pass-by-reference means. So all line 48 needs to do is return the integer.

lint 51: Get_Letter_Grade(). That function is doing too much work. Re-read the program requirements you posted and make the function do exactly what the requirements says it should do and nothing more.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what exactly is a vector?

A vector is declared in the header file <vector> and is an array that will auto expand as you add items to it. google for std::vector and you should find lots more info about it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

At some point the value of X[l2] is NULL in function merge(). The value of l2 at that point is 6 and X[6] is NULL.

You will probably have to start using your compiler's debugger to find the exact cause of that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well I found the problem -- MAXSIZE is too big. Either reduce its size to something more reasonable, such as 400, or use a vector so that the size will auto adjust to the number of items in the input file. Another option is to make allInfo global and not pass it around as a parameter.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Students * allInfo[400000] = {new Students()};
I get a stack overflow when I attempt to run that program, more than likely due to this line. That needs to be an array of pointers Students * allInfo[40000] = {0}; you don't want to allocate memory for that with new because the loop that reads the input file will do that. It would be a lot better if you used a vector of structs instead of that array, but maybe your instructor won't allow it.

The program is getting stack overflow error when the function merge() is called. I'm looking now to see if I can find out why.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

including string is not the problem my compiler takes care of that

Sorry, but compiler's do not do such things.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to include <string> because your program uses it.

please post input file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>since I've missed the past 2 classes
Don't do that! you will fall behind real fast by missing classes.

>>while(choice=100||200||300||400||500){
>> cin>>choice;
I don't think you want to make that a while statement. Move the menu lines 23-39 into another function -- maybe named menu() -- so that main() will be easier to write. Then write a loop that include menu()

bool done = false;
while( !done)
{
     int choice = menu();
     switch(choice)
    {
case 100:
   done = true;
   break;
case 200:
   done = true;
    break;
case 300:
   done = true;
    break;
case 400:
   done = true;
   break;
default:
   cout << "invalid choice\n";
   break;   

    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 21-44 -- read post #10. you put too much code in main(), most of it belongs in other functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the majority (~85%) of white english people do not go to church

In the US its about 40% who are regular church goers. Link. A political candidate who loses that many people will probably also lose the election.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So the US candidate not only has to go to church, but the right church too!

No, I didn't say that. Most any church or other religious place of warship will do. Doesn't really matter what religion either.

I understand going to church in the US is one good tax deduction possibility.

Not the going to church, but giving $$$ (there is an upper limit) to them is tax deductable as charitable contribution.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Usually this isn't a problem and C code compiles fine in .cpp source files
No it doesn't. There are many c constructs that will not compile as *.cpp file. If yours did then you were just lucky. Safest way is to always code C programs in *.c file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would get the data reading done, then the menu. Without data, it's hard to test the rest. From there, implement one action at a time, test it well. The menu will also give you direction on what you need.

But without the menu its impossible to call the function that reads the data. Well, not really, but if you do you will wind up rewriting part of the program. Besides, the menu is the simplest part of the whole program and should take no more than a few minutes to write.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>1st step would be to open the file.. and read all of the information into an array
Wrong. The first step should be to write a menu that will allow the user to select a menu item. Only after you have that working you can go on to the next step. Which is to design a structure to hold all the information for one person. Then you will need an array, vector, or linked list to hold all the structures. Again, you will compile and correct all errors.

Now you are ready to implement each of the menu items one function at a time. Compile the function and test to make sure it works correctly before moving on to the next function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If anyone else has suggestions as to where I should start and how I should go about doing this.. it would be more than appreciated. Group members are not helping :(

What's your hurry! Don't expect immediate answers to your questions, sometimes it might take a few hours depending on when you post. Getting pushy as you have done in this thread usually backfires and no one will answer you -- ever.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 5: the parameter prompt is misnamed -- should be name and passed by reference int Get_Name_and_Num_Classes(string& name); then change line 24 to use the above function prototype and change the function beginning at line 45 to do as instructed storing the name the the user typed into the parameter name and returning the number of classes. The function you wrote does not do that.

you can delete lines 23 and 24 because that info belongs in function Get_Name_and_Num_Classes().

I think the do loop lines 21-44 can be abbreviated

std::string name;
int numClasses = 0;
int sum = 0;
do 
{
    numClasses = Get_Name_and_Num_Classes(name);
    if( name != "xxx" )
    {
         GPA = Calculate_GPA(numClasses);
    }
} while( name != "xxx");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7 vijay's function declaration is wrong or just plain convoluted void copy_string_to_array( char array[N][N], const char* cstr ) >>I am having a problem for coping the string into a 2d array..

// the following array will hold up to 4 strings, and each string can be no more than 3 charcters plus the null terminator.  That means you would have to split the word "Encryption" up into 4 words of 3 characters each.  Is that what you are trying to do?
char b1[4][4]; 
strcpy(b1[0],"Enc");
strcpy(b1[1],"ryp");
strcpy(b1[2],"tio");
strcpy(b1[3],"n");

// you could just copy the whole word to array b1, but it would have to be treated as a single array as in the next example

// or do you want to just copy "Encryption" into a single array
char b1[16];
strcpy(b1,"Encryption");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

~s.o.s~ and Salem I agree with Narue on both these people. You can always count on them to provide expert opinions and advice about most every software question and have a knowledge of a wide range of languages.

WaltP is another regular whose opinions I highly respect. I don't recall him ever being wrong about anything he has ever posted. Brillient person with obviously lots of professional experience.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wonder if any candidate that admits to avoiding church visits would have any chance in hell (sorry!) to get elected?

Probably not -- we are still a nation of church-goers and every candidate must win them over in order to get elected.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Old or new type? My GF has the new type in yellow, real sharp (GF and car)!

You have a great GF, keep her around for a long time because yellow cars are the only good cars made. Did you know yellow cars have the lease number of accidents while red cars have the most ? I read that somewhere, but don't remember where.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't declare it like that. First just declare the vector object vector <problem> problems; . Then later on you can add classes to it

vector <problem> problems;
problem person;

for(;;)
{
    // enter each of the attributes of the person object is not shown

    // add a class object to the vector
    proglems.push_back(person);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Does that mean that whoever has the most boring clergy gets elected?

Yes :) :) But you will not fall asleep in any of either Graham's or Write's sermans.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Volkswagen Beetle -- cute little bug puddling down the road :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if (sign = '+')
line 31 and others similar are using the assignment operator = instead of boolean ==.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 49: Get_Name_and_Num_Classes() -- that seems to be a misnamed function. Your program expects it to return a string from line 24 but it actually returns an integer. You could hack it to return both a string and an integer but it would be a lot better to use two different functions -- GetNumClasses() and GetName(). If you do that then there will be no confusion about what it should return. And neither function needs a parameter.

line 36 of your most recent attempt is incorrect. Pass grade as the parameter, not number.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok, so another way to do it is to sum up all the grades and divide the the number of grades. Such as:

while (count <= classes)
{
    number = Get_Letter_Grade(grade);
    number = Convert_Let_to_Num(number);
    sum = sum + number;
    count = count + 1;
}
GPA = sum / classes;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

rand() never generates number in sequential order -- if it did then the numbers wouldn't be random. What you need to do is put the generated data into an array the sort the array by height.

Or put the numbers in the linked list in numerical order instead of just at the head or tail. You will need to write another function that will search the linked list to find the correct spot then insert a new node with the new hight (and other info) in that spot.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 35: you need to pass variable grade by reference to that Get_Letter_Grade() can change its value. Then in main() you need to save all the graded in an array so that the GPA can be calculated.

line 39: the value of number is never set to anything so all it is passing to Convert_Let_to_Num() is the3 value 0 (line 14)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what makes you think your program is working? The loop on line 21 doesn't stop when you press the <Enter> key. And if you just type in a bunch of crap you get this:

Please enter string for storage:
lkaslkjas;lkfjaslkfjas;lkjfg;lkjglkjerpoitjergokjjgk;lkeo;ijtoijtrhoijrt;hoijrth
oijtgoijegoijewgoiejgoierjgpoijergoijergoijwegpoijwergpoiwjergpoiwejg
The first 81 characters of the string entered were:
lkaslkjas;lkfjaslkfjas;lkjfg;lkjglkjerpoitjergokjjgk;lkeo;ijtoijtrhoijrt;hoijrth
o╠╠╠╠╠╠╠óÇÇæ|■1
Press any key to continue . . .

Notice the junk stuff at the bottom just before "Press any key ...". That's caused by the string not being null terminated.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think jephthah might have just been sarcastic with that huge post of his. Even if it worked for you don't turn it in as your assignment because your teacher will immediately recognize it as not your work and flunk you. If he/she doesn't then he's a very stupid teacher.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>i thought i turned the num from a int to a str with
All it does is put the digits of num into another variable named str. The original integer is unchanged. Its not possible to convert the data type of an an integer into a std::string or character array. All you can do is copy the digits into another variable, as you have done.