![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| read data from a file when reading data from the attached file, apart from the four corner which only associated with #s, how to only grap the data inside the 4 #s border, which are numbers 0-9 and some #s in the middle and store them into 2d array? i only want to store the numbers and the #s between the numbers inside. there is a space in between numbers and #s. there are some spaces, new line character at top, bottom, left and right of the square. below are the codes that i implemented but kind of stuck in some way as may need your help to carry on. Code: #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define row 12 /* Number of rows on square */
#define col 12 /* Number of columns on square */
int square[row][col];
int i = 0, j = 0, ch;
int main(int argc, char *argv[]) {
while ((ch = getchar()) != EOF) {
if (ch >= 0 || ch <= 9) {
for (i = row; i >= 1; i--) {
for (j = ch; j <= 23; j++) { |
| |
| |||
| I can't understand what you want correctly.But i noticed a bug in your code getchar() returns a char value but you are trying to store it in a int variable. I you can explain more the problem I think i can help you Thanks |
![]() |
| Thread Tools | |
| Display Modes | |
| |