Script does not work Windows XP

Good Morning,

I ran this script on windows 7 and tested it on windows 7, 100% ok, but not working in windows xp

Could you help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <fstream>
#include <limits>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <algorithm>

std::istream& ignoreline(std::ifstream& in, std::ifstream::pos_type& pos)
{
    pos = in.tellg();
    return in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}

std::string getLastLine(std::ifstream& in)
{
    std::ifstream::pos_type pos = in.tellg();

    std::ifstream::pos_type lastPos;
    while (in >> std::ws && ignoreline(in, lastPos))
        pos = lastPos;

    in.clear();
    in.seekg(pos);

    std::string line;
    std::getline(in, line);
    return line;
}
//converter para float
float to_float(const std::string& str)
{
   std::istringstream is(str) ;
   float result ;
   
   is >> result ;
   return result ;
}
 
int main()
{
    std::string date;
    std::string time;
    std::string t;  
    
    std::ifstream file("temp.txt");
       
    if (file)
    {
        std::string line = getLastLine(file);
        
 	std::istringstream iss(line);
        getline(iss, date, ' ');
        getline(iss, time, '\t');
        getline(iss, t); 
    }
    else {
        std::cout << "Error read temp.txt\n";
        return 2; }
        //converte temperatura para float
        std::replace(t.begin(), t.end(), ',', '.'); 
		float temp = to_float(t) ; 
        if (temp >= 27)
        {
        std::cout << "Temperature High: " << temp << " C - " << date << " " << time;
        return 2;
        }
		if (temp <= 10)
		{
        std::cout << "Temperature Low: " << temp << " C - " << date << " " << time;
        return 2;
		}
		if (temp >10 && temp <27)
		{
		std::cout << "Temp Backup: " << temp << " C - " << date << " " << time;
		return 0;	
		}
		else
		{
		std::cout << "Error Read Temp";
		return 2;			
		}

}
More information, please.

Are you compiling/building this code on Windows 7 and trying to use the same .exe on XP? What are you using to build the code? Visual Studio? Which version?
Last edited on
Also, if it's not compiling it would help for you to post the error you are getting. If it's not running, then posing any errors that come up, if any do, would still help.
the code compiles, made ​​in windows 7, but I forgot I was going to use on an old machine with windows XP

I used dev c + +
Sounds like there is a DLL version difference, which makes sense since you're rolling back two generations of OS's. The simple solution would be to compile it on the XP machine, that should be forward compatible.
good idea, I'll try
100% the XP macine does not have the redistributable installed or you are trying to run a debug version of the program.

This has nothing to do with XP vs Windows 7. The app will not run on fresh installed windows 7 machines too.
Except that Dev-C++ uses an older version of GCC by default. I suppose OP could change that but IIRC you don't need the MSVS Redist. for programs compiled in GCC.

EDIT: You mean "libstdc++-X.dll" don't you?
Last edited on
Yes, but @OP does not tell us what exactly the error is (the error message clearly stated what DLL is missing). Could be mingw10.dll or some gcc DLL or libstdc++.dll or whatever ...

A quick test on Depedency Walker will reveal the exact problem.

Dev-C++ does not even know about windows 7 existence :)
You mean "libstdc++-X.dll" don't you?

Yes, sorry about that.

However, until OP clarifies things for us "does not work" is not going to help. Maybe is not a DLL issue at all and is just the "temp.txt" file is not found ...
Last edited on
compiled in windows xp and it worked without problems!

Thank you all for the help
Topic archived. No new replies allowed.