I'm trying to write a simple code to do some statistical calculations on a table of data stored in a .csv file. Unfortunately, the first few lines of my code doesn't work. When I compile and run it, it just shows a black cmd console, and when I open the task manager, I can see 3 instances of it running, and only one of them can be shut down. I use Code::Blocks IDE with GNU:GCC compiler on Windows 7. My code is as follows:
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main(){
int length = 0;
float expmin;
float expmax;
float step;
int t;
ifstream source("D:\\statistic\\source.csv");
if (source.is_open()){
cout<<"open"<<'\n';
source.close();
}else cout<<"not open";
return 0;}
The unused variables are for later parts of the program. My other file input/output programs worked just fine. What's the deal with this, can you help me out?
Depending on my experience your program don't have the right to access that's path without admin privileges so here is the solutions that I can help with :
=> Close code-blocks >> right click on it's icon in the desktop >> Run as administrator >> execute your program again
And if the problem still exist then close your antivirus and do the same thing and if the problem still exist I think you should reinstall code-blocks or find another compiler :) :)
UPDATE
if nothing works then I think you should try your program line by line *i mean try to show message after every instruction to know where the error exactly EXP:
instruction1();
showmessage("Instruction 1 is done");
instruction2();
showmessage("Instruction 2 is done");
instruction3();
showmessage("Instruction 3 is done");
// Something like that :) :)