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 6700145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:46:46+00:00 2026-05-26T06:46:46+00:00

This is the file. X 1 0 1 1 X X 1 1 0

  • 0

This is the file.

X   1   0   1
1   X   X   1
1   0   1   0

1   1   0   X
0   X   1   1
1   X   1   0  

This is my code.. Version 1.

char cha2[1];
int patternStored[180];
for(a=0;a<(numberOfPatterns*12);a++)
    {
        fscanf(patternMatFile,"%1s",cha2);
        if(cha2[0]=='X')
        {
            patternStored[a]=2;
        }
        else
        {
            patternStored[a]=atoi(cha2);
        }
    }

The purpose of the code is to read a single character at a time and save it into the array
the above code works fine but..

at the end of the loop, i am having this error

Run-Time Check Failure #2 - Stack around the variable 'cha2' was corrupted.

This is the second version.

char cha[4];
int patternStored[180];
for(a=0;a<(numberOfPatterns*12);a++)
    {
        fscanf(patternMatFile,"%c",cha);
        if(cha[0]=='X')
        {
            patternStored[a]=2;
        }
        else
        {
            patternStored[a]=atoi(cha);
        }
    }

The second version doesn’t have error. But it only works with %d.. only digits..

I actually doesn’t know the proper way to get a single character from file using fscanf, especially the % thing.

Tkz..

  • 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-26T06:46:46+00:00Added an answer on May 26, 2026 at 6:46 am

    To get a char, you’ll want to use %c.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this C++ file: #include <iostream> int main(int argc, char *argv[]) { std::cout
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
In documentation code I see some things like this: /* * @(#)File.java 1.142 09/04/01
This is my code: File TempFiles = new File(Tempfilepath); if (TempFiles.exists()) { String[] child
I have a xaml file with this code: <GridViewColumn x:Name=lvCol3 Header=Quantità Width=120> <GridViewColumn.CellTemplate> <DataTemplate>
I can read XLS file with this code : string path =@c:\r\1.xlsx; OleDbConnection MyConnection
I write this function, but what's its return value. (defn read-data [file] (let [code
In a .f file there is code that does this: real Bob, avar ...
i need to look xsd file for generate code so i need this document

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.