-The program should print "COP 2220-50184 Project 3: <your name>" with a blank line before and after.
-Then it should prompt the user for the input file name of the file containing the data to sort.
- If the program can't open the file or if no file name is entered (^d or ^z is entered for EOF), it should print an error message and exit.
-The file will contain numbers that could be positive or negative integers or floating point numbers two numbers to a line.
-The program should only handle the first 90 numbers in the file.
-this program needs to be done in functions and not in main. I'm pretty bad at this and the only function Ive been able to accomplish is hello world. Any help would be much appreciated!! I basically dont know how to open the file and get the data into the program either.

#include <stdio.h>

// Function Declarations
void greeting();
int openFile(FILE* FP);


int main (void)
/* Local Declarations */

{
float nums[90];
FILE*FP;

greeting();
openFile(&FP);
/*Statements*/


return 0;
} /* end of Main */


/* Function Name: greeting

 * Input Parameters: none

 * Description: Function prints out class, project and name.

 * Return Value: returns statement in parenthesis.
*/
void greeting ()
{
printf("\n\nCOP 2220-50184 Project 3: Daniel Greene\n\n") ;
return;
}


int openFile(FILE** FP)
{
*FP = fopen();

printf("\n\nEnter File Name\n\n") ;
scanf("%s, fName");
Fopen(fName, "r");
if(!fName)
    {
     printf("File name not valid.\n");
    }

Line 41 - C'mon, you're not ready to open anything yet. You have to get the filename first. Delete this line.

Line 44 - You can't use a char array variable, without first declaring it. Declare fName first, then use it. (and don't make it too small).

Line 45 - No capital F in fopen. C is always case sensitive.

If the function should return an int, then you need to return an int, don't you?

Work with this, you can do much better than this. Work on the overall flow first, and put off the details for later. Check your syntax (try to compile it), when you have made changes, so you're polishing your syntax as you move along.

You never want to be left with dozens of errors and no idea where the error that caused it all, might be.

Also, do you see something strange in here?

/* Return Value: returns statement in parenthesis.
*/
void greeting ()
#include <stdio.h>

// Function Declarations
void greeting();
int openFile(FILE* FP);
MAX_SIZE [90];

int main (void)
/* Local Declarations */

{
float nums[90];
FILE*FP;

greeting();
openFile(&FP);
/*Statements*/


return 0;
} /* end of Main */


/* Function Name: greeting

 * Input Parameters: none

 * Description: Function prints out class, project and name.

 * Return Value: returns nothing.
*/
void greeting ()
{
printf("\n\computers\n\n") ;
return;
}


int openFile(FILE** FP)
{
int fName

printf("\n\nEnter File Name\n\n") ;
scanf("%s, fName");
fopen(fName, "r");
if(!fName)
    {
     printf("File name not valid.\n");
    }




return FP;
}
if(!fName)

When is string FALSE? Sorry when is filename int? What type is FP? What type is openFile? What openFile returns? Isn't it little confusing to have two FP of different types around?

The filename variable fName, needs to be a char array, not an int.

#include <stdio.h>

// Function Declarations
void greeting();
int openFile(FILE* FP);
MAX_SIZE [90];

int main (void)
/* Local Declarations */

{
float nums[90];
FILE*FP;

greeting();
openFile(&FP);
/*Statements*/


return 0;
} /* end of Main */


/* Function Name: greeting

 * Input Parameters: none

 * Description: Function prints out class, project and name.

 * Return Value: returns nothing.
*/
void greeting ()
{
printf("\n\ncomputer\n\n") ;
return;
}


int openFile(FILE* FP)
{
char fName[90];

printf("\n\nEnter File Name\n\n") ;
scanf("%s, fName");
fopen(fName, "r");
if(!fName)
    {
     printf("File name not valid.\n");
    }




return 0;
}

this is the next part of the code i need to write. It is taking the file i opened into and array which will be followed by sorting.

#include <stdio.h>
void greeting(void);
void sortArray (float *nums[], int *last);
int main()
{
float nums;
int last;
greeting();
sortArray(&float nums[90], &int last);
return 0;
}

void greeting ()
{
printf("Hello World! My name is Daniel Greene");
return;
}

void sortArray(float *nums[], int *last)
{
    int smallest;
    int temp;

    for (int current = 0; current < last; current++)
    {
        smallest = current;

        for (int walk = current + 1; walk <= last; walk++){
            if (nums[walk] < nums[smallest]){
                 smallest = walk;
                 temp = (float)nums[current];
                 nums[current] = nums[smallest];
                 nums[smallest] = (float)temp;
            }
}

return;
    }

You definately do not go to next part, you have not the first code debugged!

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.