Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. reading error

reading error

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrby123
    wrote on last edited by
    #1

    I got this error message when I debug: Unhandled exception at 0x77a915de in MSW_Vib_Model.exe: 0x00000000: The operation completed successfully. from these code segments: // ifl=0; do { { // fscanf_s(f_ptr_seed_inf,"%lf %lf %s\n",&sd_dis[ifl],&time_onset[ifl], ftitle[ifl].GetBuffer(MAX_PATH)); ftitle[ifl].ReleaseBuffer(); } ifl += 1; } while (!feof(f_ptr_seed_inf)&&(ifl<120)); nfile=ifl; // This is my input file: 4171.000 0.28600 ECO61_4171_Hole1_seeds.txt 4157.000 0.24600 ECO61_4157_Hole2_seeds.txt Please help me.

    _ 1 Reply Last reply
    0
    • M mrby123

      I got this error message when I debug: Unhandled exception at 0x77a915de in MSW_Vib_Model.exe: 0x00000000: The operation completed successfully. from these code segments: // ifl=0; do { { // fscanf_s(f_ptr_seed_inf,"%lf %lf %s\n",&sd_dis[ifl],&time_onset[ifl], ftitle[ifl].GetBuffer(MAX_PATH)); ftitle[ifl].ReleaseBuffer(); } ifl += 1; } while (!feof(f_ptr_seed_inf)&&(ifl<120)); nfile=ifl; // This is my input file: 4171.000 0.28600 ECO61_4171_Hole1_seeds.txt 4157.000 0.24600 ECO61_4157_Hole2_seeds.txt Please help me.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The problem is readying the string with fscanf_s. If you replace fscanf_s with fscanf, you will notice that it works without errors. The _s (secure) versions of the C-Runtime requires that the size of the buffer be known and this is validated by the function. So you need to pass in the size of the string as an argument following the actual string buffer as shown -

      fscanf_s(f_ptr_seed_inf,"%lf %lf %s\n",&sd_dis[ifl],&time_onset[ifl], ftitle[ifl].GetBuffer(MAX_PATH), MAX_PATH);

      Here is an excerpt from the documentation for scanf_s -

      Unlike scanf and wscanf, scanf_s and wscanf_s require the buffer size to be specified for all input parameters of type c, C, s, S, or string control sets that are enclosed in []. The buffer size in characters is passed as an additional parameter immediately following the pointer to the buffer or variable. For example, if you are reading a string, the buffer size for that string is passed as follows: char s[10]; scanf_s("%9s", s, _countof(s)); // buffer size is 10, width specification is 9

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups