I wanted to use the code blocks to draw circles. I downloaded BGI and put the files of the BGI in the correct places in the code blocks folder (and also changed the complier settings from codeblocks). However, when calling the initwindow from the main in the codeblocks, nothing happend (there isn't any window);
#include <iostream>
#include <graphics.h>
int main()
{
initwindow(900,900);
circle(90,90,90);
return 0;
}
Thanks in advance.
Related
I have a C++ code in Codeblocks in Mac OS that should create some .txt files and write something on them. It worked on Windows, however, it does not run correctly on Mac. It does not make any errors, and it announces that the procedure is terminated with status 0; however, it does not create any .txt files!! What can be the problem?
It even does not claim that Codeblocks needs special permission. Moreover, the execution window background is White; different from the usual execution window of Codeblocks, which is Black.
This is the code:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <ctime>
using namespace std;
int main(){
for (int i=1;i<=1;i++){
ofstream fout ("test1.txt");
int n=rand()%10+1;
// int n=15;
fout<<n<<endl;
}
return 0;
}
This code just does not create any .txt file in Mac, while it worked on Windows.
"test1.txt",this is a relative path, you maybe hava use clion,you must know where relative path, but it is using a absolute path.
I am learning how to link SFML so I can use the window tools. My ultimate goal is to write some sort of Chess or Asteroid game just to practice getting better at programming. I used the SFML tutorial to get all of my linking straightened out, and I am doing it dynamically with the .dll files. Everything in this code compiles on Visual Studio 2017, but when the console comes up the error I get is , "The application was unable to start correctly (0xc000007b)."
I am assuming this is some sort of memory error? It took me a while to learn the linking and now I am stuck. Thanks for any help!
PS. This is just suppose to be a simple display a window with a green circle inside of it.
#include "pch.h"
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <time.h>
using namespace sf;
int main()
{
RenderWindow window(VideoMode(200,200), "My First Window");
CircleShape shape(100.f);
shape.setFillColor(Color::Green);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
{
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}
return EXIT_SUCCESS;
}
The answer is already mentioned in the comments, but I will put an actual answer here so it's more visible.
The error code 0xc000007b means that the required .dll files are not in located in PATH or the local directory. To fix this issue, either place your required .dlls in a directory in the system PATH, or in the executable directory.
Also, you need to make sure that you do not mix 32 bit and 64 bit libraries, they are incompatible with each other.
Thank you drescherjm.
I've successfully linked all the required libraries etc. to my c++ project yet for some reason whenever i try
Mat image;
the program terminates without any errors. If i try
int main() {
cout<<"TEST";
Mat a;
return 0;
}
it wont even show the "TEST" on the terminal but simply states
(exit value: -1,073,741,515) using eclipse. Im not sure what to make of it since theres no errors and the exit value shows nothing when i search google for it. Is there anything else i could try, or have i missed something?
The code is copied below, together with the c++ build settings. The 'build' folder is a folder i created myself for cmake source directory.
Libraries included in Mingw C++ Linker
GCC C++ compiler
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h>
int main(){
cv::Mat im_gray;
return 0;
}
Thank you for reading!
I am trying to write a simple project on Dev C++ , but it seems it is not working like it should on windows 8.
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
cout<<"hello You~~"<< endl;
system("PAUSE");
return 0;
}
After compiling it, it shows an empty black screen. Am I doing something wrong?
There are known issues with running Dev-C++ 4.9.9.2 on Windows 8 (it's not that surprising, it's a program from 2005). Try a newer IDE - if you like Dev-C++, you can try Orwell Dev-C++.
Why BlockInput isn't working
#include <iostream>
#include <windows.h>
#include <winable.h>
int main() {
BlockInput(true);
Sleep(10000);
return 0;
}
and it simply doesn't block anything!
I can still do everything like I haven't even done that.what I also find weird is that MSDN sais that it should be declared in winuser.h and it is in Winable.h + I thought that winable.h is in windows.h but It's not, I had to include it seperatly >_>
If it helps my IDE is:
Code::Blocks 10.05 MinGW
EDIT: Actually I did the GetLastError() and it prints error 5 ERROR_ACCESS_DENIED
How may I get the access?
Run your code as an administrator. Right-click on the executable and click 'run as Administrator'.