Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define ROWS 50
- #define COLUMNS 50
- #define TR 100
- #define TC 100
- int main()
- {
- int sizeOfGrid = 0;
- int rowNumber = 0;
- int colNumber = 0;
- int curChar;
- int spaceCount = 0;
- int temprow = 0;
- int tempcol = 0;
- /* */
- char letters[ROWS][COLUMNS];
- char temp[TC];
- char temp2[TR][TC];
- FILE *fp1 = fopen("data1","r");
- if (fp1)
- {
- /* First, lets make sure all grids are empty. */
- for (rowNumber = 0; rowNumber < ROWS; rowNumber++)
- {
- for(colNumber = 0; colNumber < COLUMNS; colNumber++)
- {
- letters[rowNumber][colNumber] = ' ';
- }
- }
- /* Lets speak psuedocode here:
- * Search data1's first line
- * While character isn't end of line
- * If character isn't a space,
- * sizeOfGrid++ <--Count all the characters to get the dimensions.
- * ^--Note that the width and height are locked together, i.e.
- * an array with 18 width will have the same height as the width,
- * so 18 width and 18 height.
- *
- * While rowNumber and colNumber < (sizeOfGrid - 1)
- * for rowNumber = 0; rowNumber < (sizeOfGrid - 1); rowNumber++
- * for colNumber = 0; colNumber < (sizeOfGrid - 1);
- * letters[rowNumber][colNumber] gets the next character in data
- * */
- rowNumber = 0;
- colNumber = 0;
- for (temprow = 0; temprow < TR; temprow++)
- {
- curChar = fgets(temp,TR,fp1);
- for (tempcol = 0; tempcol < TC; tempcol++)
- {
- if ((temp[tempcol] != ' ') || (temp[tempcol] != NULL))
- {
- letters[temprow][colNumber] = temp[tempcol];
- colNumber++;
- }
- /* temp[tempcol] = ' '; */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment