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. what function will convert a char to its number value

what function will convert a char to its number value

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
21 Posts 8 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.
  • J johnstonsk

    Believe me I don't have to do this for a school project. I have created a tool that display flight simulator data in real time. Long story short: (this is just another feature of the program) The flight simulator writes to a file and I use the getline() function to get the names of signals that the sim wrote and put them in TSimHeader_arr[0].Name[i] which is an array in a struct. anyways I think the function (char)strdup(name.c_str())isn't putting them in the char array correctly. Because when I read them bach out they are strange characters. I don't know how to do this. Does anyone??? steven void setInitialValues(){ sSignal.SimWriteFlag=1; sSignal.DisplayReadFlag=0; sHeader.SimStatus=setSimStatus(); string name,unit,min,max,value; for(int i=0; iTSimHeader_arr[0].Name[i] = (char)strdup(name.c_str()); TSimHeader_arr[0].Unit[i] = (char)strdup(unit.c_str()); TSimHeader_arr[0].Min[i] = atof(min.c_str()); TSimHeader_arr[0].Max[i] = atof(max.c_str()); TSimSignal_arr[0].Value[i] = atof(value.c_str()); // printf("%s",TSimHeader_arr[0].Name[sig_count]); sig_count ++; } TSimHeader_arr[0].SignalCount = sig_count; writeRfmData(); createRandNum(); }

    J Offline
    J Offline
    John R Shaw
    wrote on last edited by
    #21

    Prototype: char *_strdup( const char *strSource ); Bad: (char)strdup(name.c_str()); // this is incorrect usage Good: strdup(name.c_str()); // normal usage Ok: (char*)strdup(name.c_str()); // this is redundant INTP

    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