thequadgameforces
Decapat
- Katılım
- 25 Ağustos 2020
- Mesajlar
- 678
- Çözümler
- 5
Yazdığım C++ kodu g++ ile compile ettikten sonra çalışıyor fakat kaynak kod üzerinde değişiklik yapıp tekrar compile ediip deneyince çoğu zaman çalışmıyor.
Çalışan kod:
Değişiklik yapınca çalışmayan kod:
Ben kendi kodumda saatlerce hata ayıklama yaptıysamda sorunu bulamadım.
Çalışan kod:
C++:
#include <iostream>
#include <fstream>
#include <string>
int main()
{
int good = 0;
int bad = 0;
std::string cache;
const int threshold = 10;
std::string data1[100];
std::string data2[100];
std::fstream item("merhaba1.compressed");
for (int index = 0; index <= 100; index++)
{
getline(item ,cache);
data1[index] = cache;
}
std::fstream item2("merhaba2.compressed");
for (int index = 0; index <= 100; index++)
{
getline(item2 ,cache);
data2[index] = cache;
}
cache = "";
item.close();
item2.close();
std::cout << data1[2] << "\n";
std::cout << data2[5];
std::cin >> cache;
return 0;
}
Değişiklik yapınca çalışmayan kod:
C++:
#include <iostream>
#include <fstream>
#include <string>
int main()
{
int good = 0;
int bad = 0;
std::string cache;
const int threshold = 10;
std::string data1[100];
std::string data2[100];
std::ifstream item("merhaba1.compressed");
std::ifstream item2("merhaba2.compressed");
for (int index = 0; index <= 100; index++)
{
getline(item, cache);
data1[index] = cache;
getline(item2, cache);
data2[index] = cache;
}
cache = "";
item.close();
item2.close();
std::cout << data1[1];
return 0;
}
Ben kendi kodumda saatlerce hata ayıklama yaptıysamda sorunu bulamadım.