Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:09:46+00:00 2026-05-31T20:09:46+00:00

its me again with this project. im having a problem reading the text on

  • 0

its me again with this project. im having a problem reading the text on my input cause the program never ends. The problem its here full description of the problem
but i dont know how to read the text char by char , and then read the next line the same way.

    freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);

int n=-1;
int m=-1;
int cont =0;
int VMatriz[100][100]={0};
int Mapa[100][100]={0};
while(n!=0 && m!=0)
{
    scanf("%d %d",&n,&m);

    if (n==0 && m==0)
        break;
    cont++;
    printf("Field # %d",cont);


    for (int i=0;i<n;i++)
    {   printf("/n");
        for (int j=0;j<m;j++)
        {
            //scanf("%d ",&Mapa[i][j]);
            Mapa[i][j]=getchar();

            if (Mapa[i][j]=='*')
                {
                    if (j-1>=0)
                        VMatriz[i][j-1]++;
                    if (j+1<m)
                        VMatriz[i][j+1]++;
                    if (i-1>=0)
                        VMatriz[i-1][j]++;
                    if (i+1<m)
                        VMatriz[i+1][j]++;

                    if (j-1>=0 && i-1>0)
                        VMatriz[i-1][j-1]++;
                    if (j-1>=0 && i+1<m)
                        VMatriz[i+1][j-1]++;
                    if (j+1<m && i-1>0)
                        VMatriz[i-1][j+1]++;
                    if (j+1<m && i+1<m)
                        VMatriz[i+1][j+1]++;

                    VMatriz[i][j]='*';

                printf("%d",VMatriz[i][j]);


                }

        }   

    }
    printf("/n");


}
return 0;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:09:47+00:00Added an answer on May 31, 2026 at 8:09 pm

    First make the logic simple

    1. Read Line by line till you reach the EOF
    2. Parse the line for each char

    You can use CStdioFile

    CStdioFile file (_T("File.txt"), CStdioFile::modeRead);
    CString buffer;
    
    while (file.ReadString(buffer))
    {
       CString strLine = buffer;
       //Parse the strLine for each character
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Its a .vbproj and looks like this <Project DefaultTargets=Build xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup> <ProjectGuid>15a7ee82-9020-4fda-a7fb-85a61664692d</ProjectGuid> all i
I'm trying to get into java again (it's been a few years). I never
I am having a problem with CakePHP 1.3. I'm using a jQuery plugin for
NOTE: with a little modification to the project I was able to build again
I'm creating an RPN calculator for a school project and having trouble with the
I am working on a php project and I am having problems with including
Sorry if this is a stupid noob question. I'm doing a very small project
For the project I'm working on, we have a desktop program that contacts an
I have a program below that tries to take input from the user and
I've been reading through the other posts on this topic tried what was suggested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.