View difference between Paste ID: 60nztTXP and 8H9abm1N
SHOW: | | - or go back to the newest paste.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#define ROWS 50
5
#define COLUMNS 50
6
#define TR 100
7
#define TC 100
8
9
int main()
10
{
11
	int sizeOfGrid = 0;
12
	int rowNumber = 0;
13
	int colNumber = 0;
14
	int curChar;
15
	int spaceCount = 0;
16
	int temprow = 0;
17
	int tempcol = 0;
18
	/* */
19
	char letters[ROWS][COLUMNS];
20
	char temp[TC];
21
	char temp2[TR][TC];
22
	FILE *fp1 = fopen("data1","r");
23
	if (fp1)
24
	{
25
26
		/* First, lets make sure all grids are empty. */
27
		for (rowNumber = 0; rowNumber < ROWS; rowNumber++)
28
		{
29
			for(colNumber = 0; colNumber < COLUMNS; colNumber++)
30
			{
31
				letters[rowNumber][colNumber] = ' ';
32
			}
33
		}
34
		/* Lets speak psuedocode here:
35
		 * Search data1's first line
36
		 * While character isn't end of line
37
		 * 	If character isn't a space,
38
		 * 		sizeOfGrid++ <--Count all the characters to get the dimensions.
39
		 * 		^--Note that the width and height are locked together, i.e.
40
		 * 		an array with 18 width will have the same height as the width,
41
		 * 		so 18 width and 18 height.
42
		 *
43
		 * While rowNumber and colNumber < (sizeOfGrid - 1)
44
		 * 	for rowNumber = 0; rowNumber < (sizeOfGrid - 1); rowNumber++
45
		 * 		for colNumber = 0; colNumber < (sizeOfGrid - 1);
46
		 * 			letters[rowNumber][colNumber] gets the next character in data
47
		 * */
48
49
		rowNumber = 0;
50
		colNumber = 0;
51
		for (temprow = 0; temprow < TR; temprow++)
52
		{
53
			curChar = fgets(temp,TR,fp1);
54
			for (tempcol = 0; tempcol < TC; tempcol++)
55
			{
56-
				if ((temp[tempcol] != ' ') && (temp[tempcol] != NULL))
56+
				if ((temp[tempcol] != ' ') || (temp[tempcol] != NULL))
57
				{
58
					letters[temprow][colNumber] = temp[tempcol];
59
					colNumber++;
60
				}
61
				
62
				/* temp[tempcol] = ' '; */
63
			}
64
		}