Hi, I'm taking a computer science class and one of our assignments required me to make a bar graph using xcode and sfml. We had to input a file for the heights, but my heights aren't working. I've attached my code below. Please take a look at it! Thank you!!!!//
// Disclamer:
// ----------
//
// This code will work only if you selected window, graphics and audio.
//
// In order to load the resources like cute_image.png, you have to set up
// your target scheme :
//
// - Select "Edit Schemeā¦" in the "Product" menu;
// - Check the box "use custom working directory";
// - Fill the text field with the folder path containing your resources;
// (e.g. your project folder)
// - Click OK.
//
int main(int argc, char const** argv)
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 800), "SFML window");
//create a file input stream
fstream inputFile("/Users/erinbell/Desktop/tmp/data5.txt");
// next create to variables to hold the
// data I want to read in
int width1;
int height1;
int width2;
int height2;
int width3;
int height3;
int width4;
int height4;
int width5;
int height5;
//Now move the rectangle to a different position
rec1.move(200, 700); // This moves the Rectangle over 200 pixels and down 700 pixels
rec2.move(300, 700); // This moves the Rectangle over 300 pixels and down 700 pixels
rec3.move(400, 700); // This moves the Rectangle over 400 pixels and down 700 pixels
rec4.move(500, 700); // This moves the Rectangle over 500 pixels and down 700 pixels
rec5.move(600, 700); // This moves the Rectangle over 600 pixels and down 700 pixels
// Set Rectangle to Green, Blue, Pink, Red
rec1.setFillColor(sf::Color(100,250,50));
rec2.setFillColor(sf::Color(10,20,100));
rec3.setFillColor(sf::Color(500,600,700));
rec4.setFillColor(sf::Color(200,300,50));
rec5.setFillColor(sf::Color(10,100,45));
//Draw in Graphic Window
window.clear();
//Now Draw My Rectangle
window.draw(rec1);
window.draw(rec2);
window.draw(rec3);
window.draw(rec4);
window.draw(rec5);