hey me and my group are doing a project but we dont know how to use the file pointer (to export the C program to a text file and we dont know how to make it so the random generator makes our words go diagonal top left bottom left top right bottom right =/ can someone help project is due by 12 am and thats the only thing we are missing

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

void makeUpper (char *s);
void menu (void);
int numberGenerator(int min, int max);
char characterGenerator(void);

main() {
	    int i = 0, i2 = 0, j = 0, wordcount = 0, cancel = 0, run = 1, posx = 0, posy = 0, pass = 0, direction = 0;
        char temp[50], words[10][16], puzzle[25][70], condition;
        
        do {
        
        system("cls");
        menu();
        
        scanf("%c", &condition);
        condition = toupper(condition);
        
        switch (condition)
        {
        case 'A'://ENTER UPTO 16 WORDS
                system("cls");
             	do {
             	printf("Enter a new word to add to the puzzle <S to Stop>: ");
		        scanf("%s", &temp);
                makeUpper(temp);
		        if(temp[0] == 83 && temp[1] == 0) 
                {
                 system("cls");
			     cancel = 1; //If the user enters "S", then cancel them out
                 if (i < 1)
                 {
                  printf("That is not enough. You must enter atleast one word. Fool.\n");
                  cancel = 0;
                 }
                } 
                else 
                {
		         if(strlen(temp) <= 10) 
                 {
				  for(i2 = 0; i2 <= strlen(temp); i2++)  //Add the word to the array
                    {words[i][i2] = temp[i2];}
				  i++;
				  wordcount++;
				   if (i > 16)
                   {
                   cancel = 1;
                   printf("That is enough. You have entered more than 16 words... Genius\n");
                   system("pause");
                   }
                 } 
                 else{printf("Word must be 10 letters or less.\n");} //If the word is more than 10 letters 
	      	  }
	        } while(cancel != 1);
	        break;
	
	    case 'B': //DISPLAY CROSSWORD
	         //Grid Entry Position Generation
             do 
             {
             posx = numberGenerator(0,69);
             posy = numberGenerator(0,24);
             if (puzzle[posx][posy] != ' ')
             {pass = 1;}
             }while(pass == 0);
             
             /*Direction Randomizer
	         UP - 1 	      UP-RIGHT - 2 	    RIGHT - 3 	    DOWN-RIGHT - 4 	    
             DOWN - 5         DOWN-LEFT - 6	    LEFT - 7 	    UP-LEFT - 8
             */
             direction = numberGenerator(0,7);
             
             switch (direction)
             {
              case 0:
                   break;
              case 1:
                   break;
              case 2:
                   break;
              case 3:
                   break;
              case 4:
                   break;
              case 5:
                   break;
              case 6:
                   break;
              case 7:
                   break;
             }
             
             for (i = 0; i < 25; i++)
             {
              for (j = 0; j < 70; j++)
              {
               puzzle[i][j] = ' ';
               printf("%c", puzzle[i][j]);
              }
              printf("\n");
              }
              system("pause");
              break;
           
        case 'C': //EXPORT TO FILE
             if (wordcount > 8)
             {
             for (i = 0; i < 16; i++)
               {
                for (j = 0; j < 10; j++)
                {
                 printf("%c", words[i][j]);
                }
                printf("\n");
               }
              }
              break;
        
        case 'D': //EXIT
             run = 0;
             break;
      }
     }while (run == 1);
}

void menu(void)
{
        printf("##########################################################\n");
        printf("#                   CROSSWORD PUZZLE                     #\n");
        printf("#                BY: HARIS, MARK, ONIEL                  #\n");
        printf("##########################################################\n");
        printf("#                                                        #\n");
        printf("# A) Enter upto 16 words to create puzzle                #\n");
        printf("#                                                        #\n");
        printf("# B) Display crossword.                                  #\n");
        printf("#                                                        #\n");
        printf("# C) Export to file.                                     #\n");
        printf("#                                                        #\n");
        printf("# D) Quit                                                #\n");
        printf("#                                                        #\n");
        printf("##########################################################\n");
}

void makeUpper(char *s)//Function that makes all characters uppercase in any string
{
	char  *p;
	for (p = s; *p != '\0'; p++) 
    {
	 *p = (char) toupper(*p);
	}
}

char characterGenerator(void) 
{
    char c;
    srand( (unsigned int) time(NULL));
    c = (rand() % 26) + 'a';
    c = toupper(c);
    return c;
}


int numberGenerator(int min, int max) 
{
    static int Init = 0;
    int rc;
    if (Init == 0) 
    {
     srand(time(NULL));
     Init = 1;
    }
    rc = (rand() % (max - min + 1) + min);
    return (rc);
}

hey me and my group are doing a project but we dont know how to use the file pointer (to export the C program to a text file and we dont know how to make it so the random generator makes our words go diagonal top left bottom left top right bottom right =/ can someone help project is due by 12 am and thats the only thing we are missing

I think you and your group are making the gross assumption that we are on the same project as you....Please post a coherent question, this makes no sense.

Edited 5 Years Ago by gerard4143: n/a

I think you and your group are making the gross assumption that we are on the same project as you....Please post a coherent question, this makes no sense.

This is a group assignment. Each group member must create at least two functions (including main). You can have many more if you want. The program is to generate a puzzle search game SHEET ONLY. The program will input between 1 and 16 words. The program will create a word search puzzle such as follows
COMMITMENTAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
HOCKEYSUPPOYOUNEVERKNOWDEARHOWMUCHI LOVE YOUSOPLEASEDONTTAKEMY
DISNEYRIDELIGAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
ASTROASTRORAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
HARRYPORTERRAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
LATENIGHTTVTAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
VALUEROOMSSAPPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMHOMESHOMESYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUDRYDRYDRYDRYAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYSEASONSEASONWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREFLOODINGFLOOGREYS
APPLEYOUAREMYSUNSHINERIVERRIVERRIVYOUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYMAGICMAGICOUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHWINDWINDWIAPPYWHENSKIESAREGREYS
APPLEYOUAAAAAAAAAAARBBYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOBBBBBBBBBBUMAKEMEHAPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHABBBBBBBBBBPPYWHENSKIESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKICCDAEAEAQQESAREGREYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGREGEADESSESEEYS
APPLEYOUAREMYSUNSHINEYOUMAKEMEHAPPYWHENSKIESAREGRADGAGASEASEEYS

You are to generate 70 letters in a row and 25 rows. You are to randomly place the words into the grid. The words can be placed in one of eight directions. You must allow for the words to cross each other. Once the 1 to 16 words have been placed into the grid you are to fill in the remaining places with other letters. Once you have the grid completed (all words entered and all spaces filled in), you are to create a list of the 1 to 16 words under the grid in two columns in alphabetical order. The output needs to go to the screen and to a text file. Please remember this program is not playing a game only building a hardcopy word search puzzle.

This article has been dead for over six months. Start a new discussion instead.