Login Page - Create Account

Support Board


Date/Time: Wed, 01 May 2024 22:54:37 +0000



Post From: C++ std::string to SCString

[2020-08-26 11:25:44]
User253985 - Posts: 21
How do i get characters from a std::string into a SCString.

example

const char* SheetCollectionName = "TesterWesterSpreadsheet";
  const char* SheetName = "Sheet1";
  void* SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false);

  std::ifstream longs (testerwester.csv");
  SCString messagee = "File Open Error";
  if(!longs.is_open())sc.AddMessageToLog(messagee, 0);
  
  std::string date; // cant change these string's to SCString's because loop won't work
  std::string time;
  std::string value;
  std::string vvalue;
  
  for(int i = 1; i < 6; i++){
  
    std::getline(longs,date,',');
    std::getline(longs,time,',');
    std::getline(longs,value,',');
    std::getline(longs,vvalue,'\n');
    
    
    SCString date = date; // This doesn't work, i need to know how to make it a SCString
    SCString time = time; //
    SCString last = value;
    SCString volume = vvalue;
    
  
    // populates built in spreadsheet
    sc.SetSheetCellAsString(SheetHandle, 0, i, date); // I think the string has to be a SCString?
    sc.SetSheetCellAsString(SheetHandle, 1, i, time);
    sc.SetSheetCellAsString(SheetHandle, 2, i, value);
    sc.SetSheetCellAsString(SheetHandle, 3, i, vvalue);  
    }
    longs.close();

Output is blanks, the getline loop works,





cheers :-)