Jump to content

fizzlesticks

Member
  • Posts

    1,196
  • Joined

Everything posted by fizzlesticks

  1. Most C is valid C++ yes, but that hasn't been true for a long time.
  2. It's not that long, the easiest thing to do would be just retype it by hand.
  3. Starting the line with a '/' will make it relative to the .gitignore file. So in your case you would do /cache/
  4. Java is still one of the most popular web dev languages, it's just as good as anything else out there (besides Java and Oracle being terrible in general.)
  5. if(start=NULL) Typo there. To avoid those kind of things it's a good idea to put the literal value on the left if(NULL == start) that way if you miss one of the '=' you get a compile time error instead of a runtime bug.
  6. Correct. Not allowing recursion is definitely the way to go.
  7. Because they're template arguments, doing template <typename First, typename ... Args> std::string TStringFormat(const char *formatting, First&& first, Args&& ... args) Would make them forwarding-references / universal-references, not rvalue references. It would be beneficial for any type that could be converted to a string by moving. So for a std::string you would do a move instead of a copy and user defined types would be able to take advantage of it. For example, if you wanted a Book to be toStdString-able and the string is just the title of the book you could have the overload: std::string toStdString(Book&& rhs) { return std::move(rhs.title); } Also I don't know if it was intentional but your function is inconsistent for strings with recursive "{x}"s. std::cout << TStringFormat("{0} {1}", "{1}", 20); //outputs "20 20" std::cout << TStringFormat("{0} {1}", "{10}", 20); //ouputs "{10} 20" I would expect either the first to output "{1} 20" or the second to throw an index out of range exception depending on if you want to allow recursive look ups or not.
  8. You're missing #include <sstream> The static_cast<std::string>s in toStdString are unnecessary. They will basically get transformed into static_cast<std::string>(std::string(rhs)); making the cast pointless. If you want to be explicit about it, just doing return std::string(rhs); would be better. The parameters for TStringFormat should all be const.
  9. glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(GLfloat), &vertices[0], GL_STATIC_DRAW); Each vertex has x,y,z and w so the size needs to be vertices * sizeof(float) * 4 Your sphere and camera are both sitting at the origin which means you won't be able to see anything. Move the camera some by creating a view matrix and multiplying it by the projection before sending it to the shader. mv = glm::mat4(1.0); glm::mat4 view = glm::lookAt( glm::vec3(0, 0, -30), //position glm::vec3(0, 0, 0), //point to look at glm::vec3(0, 1, 0) // up vector ); auto pv = projection * view; glUniformMatrix4fv(projection_loc, 1, GL_FALSE, &pv[0][0]);
  10. The count parameter in glDrawElements should be the number of indices to draw, not the number of vertices. Other than that, have to you tried drawing a simple triangle at the center of the sphere to make sure your camera and matrices are correct? edit: also you're storing indices as ints but telling glDrawElements they're GL_UNSIGNED_SHORTs, those types need to match.
  11. I too saw that video and here's a Python version written in the worst way possible. print(f'Pi = {__import__("math").sqrt(6/(lambda gcd, randint: (lambda x: x.count(1) / len(x))([gcd(randint(0,1000000), randint(0,1000000)) for _ in range(1000000)]))(__import__("math").gcd, __import__("random").randint))}')
  12. Visual Studio Community edition is already free. https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15 edit: their download servers suck so you might have to reload the page a few times.
  13. if (readString.indexOf("LED=0") >0){ digitalWrite(led, LOW); } if (readString.indexOf("LED=1") >0){ digitalWrite(led, HIGH); } You're never setting readString.
  14. You can use the Fraction type and either leave it as a fraction or check the denominator for a 1 to convert to int or convert to float for anything else.
  15. Objective-C used the same tool for building GUIs as Swift and IMO is by far the best GUI designer for any language/platform, even before the Swift era.
  16. for (i = 0; i <=40; i++) An array with size 40 starting at index 0 means the max index is 39. By going up to 40, you're overwriting some other value on the stack leading to it being corrupted.
  17. Here's how I would comment those 2 files. A comment that says, "ask the user to enter an object's mass in killograms (kg)" when the next line is input("enter object mass") is useless. Repeating yourself just for the sake of having comments actually makes the code harder to read.
  18. '10' as a character literal causes it to overflow and probably isn't doing what you expect it to. Other than that, it's hard to help if you don't say what the problem you're having is.
  19. You're writing to stderr but flushing stdout. stderr should only be used for errors. You can't clear the screen in IDLE. You can print a bunch of blank lines but that will look horrible, best option is to fix the other problem and run it outsite of an IDE.
  20. You can avoid writing your own try/catch in a lot a places but in Python you can't even write a for loop without relying on exceptions (not that it's really an issue, just how the language was designed.)
  21. 1. You don't initialize lineNum to 0. Depending on your compiler and optimization settings this may be done for you but don't rely on it, once you turn on optimizations your program will break. 2. In your loop reading the file you do purchases[lineNum][j] = n; but in the other loop you do stof(purchases[2][y]); where y is a counter based on lineNum, did you mean to do purchases[y][2]? 3. In the second loop you do for(int y = 0; y <= lineNum; y++) it should probably be y < lineNum, not <=
  22. Sounds like you're going out of bounds of the array. Would need more code to be sure.
×