Hello, I am relativly new to programing, and I need some help on a lab project. If anyone out there can explain why I am getting the following errors.

55: inlab was not declared in this scope
In funtion void selectionSort(char (*)[25], int)
74:error: Stropy was not declared in the scope
77:error: Stromp was not declared in the scope
77: expected ';' before ) token

The Lab Assignment was to write a program so that the user reads 6 words or names into an array from a file. The unsorted array is then printed out on the screen.
Then using the Selection Sort for these words/names, they are sorted and the sorted array is printed out on the screen.

Below is the code I have written, How can I fix these errors. Any kind of help with this would mean a world of diffence. Thanx in advance.

// programmer: David Pfaff
// date: April 25, 2008
// username: dpfaff



#include <cstring>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
using namespace std;

const int MAXCHARS = 25;
const int MAXSIZE = 6;
typedef char String [MAXCHARS];
String array[MAXSIZE];

// opens an input file called in.dat
// outputs: if no failure, infile is open
//    else prints message and program stops
// usage: openInputFile (infile);
void openInputFile (ifstream& infile);

// sorts a list of words
// inputs: array[0..size-1]
// outputs: array
// usage: selectionSort (nums, MAXSIZE);
void selectionSort (String array[], int size);

// enters a list of words
// inputs: a list of words
// outputs: a list of words in array
// usage:
void enter (ifstream& infile, String array[], int size);

// prints a list of words
// inputs: a list of words in array
// outputs: a list of words separated by commas
// usage:
void print (String array[], int size);

// prints a number of new lines
// inputs: num, the number of new lines
// outputs: num new lines
// usage: printNewLines(3);
void printNewLines (int num);



int main()
{
   ifstream infile;
   openInputFile (infile);
   openInputFile(inlab.dat);
   String array [MAXSIZE];
   enter (inlab.dat, array, MAXSIZE);
   print (array, MAXSIZE);
   printNewLines(3);
   selectionSort (array, MAXSIZE);
   print (array, MAXSIZE);
   inlab.dat.close();
  
   return 0;
}

void selectionSort (String array[], int size)
{
   int start, minIndex, minValue;
  
   for (start = 0; start < size - 1; start++)
   {
      minIndex = start;
      Strcpy(minValue, array[start]);
      for (int index = start + 1; index < size; index++)
      { 
         if (Strcmp(array[index], minValue) < 0))
         {
            Strcpy(minValue, array[index]);
            minIndex = index;
         }
      }
     Strcpy(array[minIndex], array[start]);
     Strcpy(array[start], minValue);
   }
}
// opens an input file called in.dat
// outputs: if no failure, infile is open
//    else prints message and program stops
// usage: openInputFile (infile);
void openInputFile (ifstream& infile)
{
   infile.open("inlab.dat");
   if (infile.fail())
   {
      cout << "Error opening input file" << endl;
      exit(1);
   }
}



// enters a list of words
// inputs: a list of words
// outputs: a list of words in array
// usage:
void enter (ifstream& infile, String array[], int size)
{
   for (int i = 0; i < size; i++)
   {
      infile >> array[i];
   }
}

void print (ifstream& infile, String array[], int size)
{
   printNewLines(2);
   for (int i = 0; i < size; i++)
      cout << array[i] << ", ";
   printNewLines(2);
}

// prints a number of new lines
// inputs: num, the number of new lines
// outputs: num new lines
// usage: printNewLines(3);

void printNewLines (int num)
{
   for (int k = 0; k < num; k++)
      cout << endl;
}

> 74:error: Stropy was not declared in the scope
> 77:error: Stromp was not declared in the scope
You wrote these out didn't you, rather than copy and paste them?

If you transcribe this stuff by hand, you're just going to add to the errors which are already there, and make it harder for us to figure out your problems.


> Strcpy(minValue, array[start]);
> if (Strcmp(array[index], minValue) < 0))
See, these are the actual calls, with a 'c' and not an 'o'

In any event, it's strcpy and strcmp, ie, all lower case.

In future, use [code]
[/code] tags for large blocks of code. [icode]
[/icode] is meant for single lines embedded in normal text.

You are correct, however I did use the 'c' and not the 'o' for the calls. So I don't think that is the problem here. Thanks checking it out though.

So did fixing the case of initial letter fix the problem?

No, I still have the errors I'm not sure why, I double checked it and I belive they are all in the proper case. check it out

// programmer: David Pfaff
// date: April 25, 2008
// username: dpfaff



#include <cstring>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
using namespace std;

const int MAXCHARS = 25;
const int MAXSIZE = 6;
typedef char String [MAXCHARS];
string array[MAXSIZE];

// opens an input file called in.dat
// outputs: if no failure, infile is open
//    else prints message and program stops
// usage: openInputFile (infile);
void openInputFile (ifstream& infile);

// sorts a list of words
// inputs: array[0..size-1]
// outputs: array
// usage: selectionSort (nums, MAXSIZE);
void selectionSort (string array[], int size);

// enters a list of words
// inputs: a list of words
// outputs: a list of words in array
// usage:
void enter (ifstream& infile, string array[], int size);

// prints a list of words
// inputs: a list of words in array
// outputs: a list of words separated by commas
// usage:
void print (string array[], int size);

// prints a number of new lines
// inputs: num, the number of new lines
// outputs: num new lines
// usage: printNewLines(3);
void printNewLines (int num);



int main()
{
   ifstream infile;
   openInputFile (infile);
   openInputFile(inlab.dat);
   string array [MAXSIZE];
   enter (inlab.dat, array, MAXSIZE);
   print (array, MAXSIZE);
   printNewLines(3);
   selectionSort (array, MAXSIZE);
   print (array, MAXSIZE);
   inlab.dat.close();
  
   return 0;
}

void selectionSort (string array[], int size)
{
   int start, minIndex, minValue;
  
   for (start = 0; start < size - 1; start++)
   {
      minIndex = start;
      strcpy(minValue, array[start]);
      for (int index = start + 1; index < size; index++)
      { 
         if (strcmp(array[index], minValue) < 0))
         {
            strcpy(minValue, array[index]);
            minIndex = index;
         }
      }
     strcpy(array[minIndex], array[start]);
     strcpy(array[start], minValue);
   }
}
// opens an input file called in.dat
// outputs: if no failure, infile is open
//    else prints message and program stops
// usage: openInputFile (infile);
void openInputFile (ifstream& infile)
{
   infile.open("inlab.dat");
   if (infile.fail())
   {
      cout << "Error opening input file" << endl;
      exit(1);
   }
}



// enters a list of words
// inputs: a list of words
// outputs: a list of words in array
// usage:
void enter (ifstream& infile, string array[], int size)
{
   for (int i = 0; i < size; i++)
   {
      infile >> array[i];
   }
}

void print (ifstream& infile, String array[], int size)
{
   printNewLines(2);
   for (int i = 0; i < size; i++)
      cout << array[i] << ", ";
   printNewLines(2);
}

// prints a number of new lines
// inputs: num, the number of new lines
// outputs: num new lines
// usage: printNewLines(3);

void printNewLines (int num)
{
   for (int k = 0; k < num; k++)
      cout << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.