Output is being prefixed with gabage
BozoTClown opened this issue · 6 comments
Hello,
I am trying to write a simple program and cannot get past the first part of reading an ini files. I saw you library and downloaded and installed it. It is reading my ini file but the output is being prefix with some sort of gabage. For now I only have the ini portion of the code so here it is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include
#include
#include "mini/ini.h"
using namespace std;
int main()
{
mINI::INIFile file("clean-folders.ini");
mINI::INIStructure ini;
file.read(ini);
std::string dFolder = ini.get("folder").get("location");
std::string delay = ini.get("purge-minutes").get("min");
printf("%s" "%s" "%s", dFolder, delay, "\n");
return 0;
}
What does your INI file look like?
Sorry, I forgot to supply that.
[folder]
location = C:\Users\Bozo\Desktop\Garbage
[purgeminutes]
min = 1
Yeah, sorry the problem isn't the INI file, it's you're trying to printf a std::string. You should do printf("%s" "%s" "%s", dFolder.c_str(), delay.c_str(), "\n");
and then it will work. Preferably, avoid using printf in C++ and use std::cout instead.
I was not ignoring you. I was trying other options prior to replying. I do thank you for pointing out my error with the printf command. I am new to C++ and am always open to sugestions. No matter what I do I am still getting garbage in the dFolfer variable prefixing my ini key data. Seems I am not allowed to attach pictures be I have one of the actual variable with "0x1f40a0" preceeding my data in the variable.
Really sorry, can't edit previous message so here I go again. Seems as though there is garbage prefixing data. It prints out correctly as you said it would. Sorry to raise this false error on a rooky mistake. Excuse the nut behind the keyboard!
No problem. :) Good luck!