C++ Definition and 813 Threads

  1. J

    Comp Sci Calculating Probabilities in C++

    Homework Statement Working on a program that will calculate the results of a shootout between 3 people, each of whom have a different level of accuracy (one hits his mark 1/3 of the time, one hits his mark 1/2 of the time, one hits his mark 1/1 of the time). Homework Equations...
  2. K

    C/C++ Debugging C++ Code to Read CSV File

    I am trying to read from a csv file, the file looks like below: 1,2,3 4,5,6 7,8,9 0 I used getline(Input_file,size,',') but the problem with this is that it seems to see the numbers not separated by commas as one string., for the code below i was expecting the following output: 1...
  3. B

    C/C++ What are some simple and free resources for a C++ compiler?

    It's been years since I last programmed in C++ and I want to brush up on it over the next couple weeks. Problem is I have no idea what's out there that I could use for programming/debugging C++ programs; the compiler I used before came on a CD with the textbook, but now I'm completely on my own...
  4. K

    Comp Sci Problem with getline in C++ programming

    Homework Statement I am solving a problem in which I am reading numbers from cells in a csv file, I used getline to get strings from the csv file then converted the string to an integer... but the getline seemingly discards the last cell in the csv file Homework Equations this my C++...
  5. CFDFEAGURU

    C/C++ Passing a VBA array to a C++ dll - Example Needed

    Hi all, In the book "Financial Applications Using Excel add-in Development in C/C++" 2nd edition by Steve Dalton in Section 3.7.2 Passing arrays and ranges from Excel to VBA to C/C++ and in that section a description of how this can be done is given. No example of how to do this is given and...
  6. M

    C/C++ C++ implementation of Longman's method, and special functions

    Hi all, I'm a programming newbie teaching myself C++ mainly for interest/ because I might want a real job after my physics PhD, but I have a problem in my research some code might be useful for. I have some functions defined by integrals of the form $$A(q)=\int db~ b* J_{0}(b*q)...
  7. W

    C++ for High Energy Physics: Reference and Textbook Guide

    Hi all; I'm a physicist _High Energy Physics Major_ and i use some computer software that is based on C++ Programming Langauge such as (ROOT data analysis frame work - Pythia event generator) and i need a reference or textbook that learns me C++ effectively, i have some choices: 1)Object...
  8. C

    C/C++ How Does Euler Integration Affect Collision Handling in a C++ Gravity Simulator?

    Hi everyone, I am new here, nice to meet you. For fun I am trying to make a gravity simulator in c++ and using SDL. I believe there is a problem in my merge function when I calculate the new velocity and trajectory of two colliding bodies. Also, does my main code look accurate. The part...
  9. P

    C/C++ How Can I Determine the Collided Side in C++ Collision Detection?

    My problem is not so much with programming it, but rather determining which side is collided. And for those who aren't familiar with SDL, SDL_Rect is just a structure that hold an x and y position along with a width and height ( (x,y) is the top left corner of the rectangle). So here is how...
  10. R

    Comp Sci Regarding C++ Problem Disscusion

    i made a c++ login program but There is Problem occurred During Compairing a Given user name (string ) with a Pre defined String. Please give me some solution of it. program #include<iostream.h> #include<conio.h> #include<string.h> class converter { public: double i,j; char m...
  11. W

    Which Edition of C++ Primer is Best for Particle Physicists?

    Hello I'm asking for a textbook in C++ programming language for Particle Physicists
  12. D

    C/C++ C++ Rotation function works in 2D perspective but fails in 3D

    I'm making a 3D rotation of a poligon.The problem is when I rotate some points in 2D, it works, but if I use the same function to rotate the same points in a 3D perspective , while rotating the vertices move to the center of the object and remain there. I also wrote the 3D rendering part.At...
  13. D

    Octave with C++ on Fedora 16 | Finding oct.h

    Hi all, I'm using Fedora 16 and installed Octave thru Yum. There is an example in the Octave manual of using Octave with C++ and it #includes a oct.h file. However, the Fedora build may not have compiled the oct.h library ? or I'm searching in the wrong places. Has anyone had any...
  14. B

    C/C++ Counting '1' Bits in Binary Blocks - Fast C++ Code

    Hi, For example, say we have the binary integer 101010 and I split it into blocks, say (1)(01)(01)(0). The size of the blocks is determined by some function. We want to count the number of '1' bits inside each of these blocks. I'm interested in a fast C++ code to do this. There are fast...
  15. F

    C/C++ Trouble with OpenMPI Bcast in C++

    Hey gang, I'm trying to use MPIBcast to distribute a user entered value across all nodes, but it seems like only the root node is working (i.e. no broadcast). I'm using OpenMPI 1.5.4 with the following code: A=0; std::clock_t start; double duration; start = std::clock()...
  16. T

    C/C++ Confused about logical statements in C++

    Maybe this should belong in the logic section. But since this is C++, ill put it here. bool isLeapYear( int y) { return y%4==0 && y % 100 !=0 || y% 400==0 ; } They said it returns when y is divisible by 4 but not by 100 unless it is also divisible by 400. This is a bit...
  17. M

    C/C++ Maximum combined length of command line arguments in c++

    In a c language, what is the maximum combined length of command line arguments including the space between adjacent arguments.?
  18. C

    C/C++ How to Solve Large Integer Powers in C++?

    Hello everybody! Here I wrote simple code for power of n number. At result I need to get an integer value. But my code works only small number of power. (Here in my code is p: 10^p). If I increase p number, then the result will be like this: 2.74*10^6=2.7e+006. But I need the result will be...
  19. A

    C/C++ How Can I Fix Template and Non-Member Function Issues in MS Visual Studio C++?

    This little test of templates and non-member functions works fine: // test5.cpp : main project file. #include "stdafx.h" using namespace System; template <class T> void mytest(void); int main(array<System::String ^> ^args) { mytest<double>(); mytest<int>()...
  20. J

    Comp Sci Fix C++ Compiling Error - Need Urgent Homework Help | CreditAccount

    Homework Statement Well I have written my entire program for my assignment, but I cannot get it to compile without multiple instances of the same error: "expected primary-expression before ']' token. Can anybody see a mistake I am making? I would greatly appreciate your help, thank you...
  21. D

    C/C++ C++ help- my code reads from small files but not large

    Hello, I'm trying to make part of a code that reads a csv file with data containing the date and time, and the wind speed at that time, then does various output things. When I copy and paste 1000 entriesinto a csv file and ru it, it works great, but if I use the file that's about 6,000kb it...
  22. A

    Comp Sci 90 degree rotation of a 2D array in c++

    Homework Statement I am trying to rotate a 2D array of type string. I am not sure what the problem is with my function. Flipping does occur but for some reason, it's not by 90. Homework Equations The Attempt at a Solution The program consists of a function and the main. Here's...
  23. A

    Comp Sci Transfering data from a text file into a 2D vector array in c++

    Homework Statement I am attempting to transfer the data from a file into a 2D vector array. The data look like this: 1 2 3 4 5 6 7 8 9 However, the dimensions must be detected dynamically. Homework Equations The Attempt at a Solution There are two files in this code, but I attempted to...
  24. M

    Comp Sci Where to save .dat file for C++ programming

    Homework Statement I'm starting my C++ project which requires me to call a file stream and output the data to four other output streams. Before I start, I want to know if I need to have a .dat file premade and saved somewhere so I can call it or do I just make that file in my code by using...
  25. Whovian

    C/C++ C++ array with variable no. of elements?

    #include <iostream> using namespace std; int a; int main() { cin >> a; int c [a]; for (int i = 1;i!=a+1;i++) { c [i] = i; } for (int i = 1;i!=a+1;i++) { cout << c [i] << endl; } return 0; } This compiles and does exactly what it's supposed to. But wait...
  26. Whovian

    C/C++ C++ functional programming problem

    As a basic exercise in C++ functional programming, I wrote the following code: #include <iostream> #include <string> using namespace std; template <class T> void Wib (T& a,T& b) { T temp = a; a = b; b = temp; }; int main() { string A = "World!"; string B = "Hello, "; Wib <string>...
  27. Whovian

    C/C++ C++ Prime Testing: Find & Fix Errors

    Alright. I know how incredibly inefficient this algorithm is, but I felt like giving this a whirl. #include <iostream> #include <cmath> using namespace std; bool prime(int x) { bool j = true; for (double i = 2;i == x;i++) { if (x/i == floor(x/i)) { j = false; } } return j; }...
  28. T

    Anyone know of a good OOP plotter for C++

    I'm interested in a lot of science involving ODEs, PDEs, and discrete functions of up to 4 dimensions (one of time). Can anyone suggest a library that would be capable of plotting even a subset of that?
  29. J

    Comp Sci C++ Why is my function printing TWICE?

    Homework Statement My printArray function, when called in my int main() with the arguments ("***monthly total***, sums, NUM_MON) is printing out twice as many times as it should be, and for some reason, even the string caption is printing out as "******monthly total******" instead of...
  30. J

    Comp Sci Why Does My C++ Array Program Give a Cannot Convert Double to Double Error?

    Homework Statement I am not completely finished with the assignment, but I was trying to test to make sure that my functions "low" and "high" would in fact return the proper value (the lowest number in the array, and the highest number in the array, respectively). However, when I compile, I...
  31. A

    Comp Sci C++ User-defined function to calculate the smaller string?

    Homework Statement I came across some codes that calculate the smaller string using user-defined functions. I tried figuring them out, but some parts I don't get. This is the first one: bool isShorter (string& s1, string& s2) { // the string objects may be large! return...
  32. Dembadon

    Comp Sci Programming: Fraction Arithmetic in C++

    This program has been assigned in my intro to programming course, which assumes no previous knowledge of programming. Up to this point we've only been required to write functions that accomplish specific tasks within a program. This is the first time we've been asked to design and write a full...
  33. Z

    C/C++ Simple C++ method question (overloading?)

    Hi, If I have a method that takes in say 5 new variables and assigns 5 class variables to these new values, and I only wanted to change one of these variables, is it possible to reuse this method and only have it take in say 1 new variable and change one class variable without having to write...
  34. S

    What C++ Books Are Best for Mathematicians with Limited Unix Experience?

    I am an electrical engineer who does quite some engineering math in my work. I also need to use computers quite a bit, but ALWAYS find the entire culture of unix and C/Fortran coding intimidating. Here is an example: I tried to compile my "hello.cc", I typed "gcc hello.cc" and got "a.out". I...
  35. S

    C++ Programming for Beginners for Engineering Students

    Hello all, I am looking for an excellent book on C++ programming to read during the summer. I have never programmed before, so it would most definitely have to be at the calliber of a beginner. I'm looking for a book that begins with basics such as algorithms, pseucode and then the actual...
  36. T

    Comp Sci C++ compare strings program using pointers

    Homework Statement Create a function called isEqual(). isEqual() takes two strings and determines if the strings are identical. isEqual (s1, s2) should be the same as s1 = = s2 #include "stdafx.h" #include <iostream> using namespace std; bool isEqual(int *s, int *st, int x); int...
  37. Z

    C/C++ C++ how to check for variable type?

    So, I want to use cin >> to get a user input that must only be int. How can I check the type of the input? Thanks.
  38. Z

    C/C++ C++ how to compare two objects of the same class?

    Hi, noob question here, In C++, how can I return boolean comparison between two object pointers? ie. return True if the pointers point to same object. I've tried == but it doesn't work. Do I need to define a comparison method from within the class? If so what is the syntax for doing it? Thanks.
  39. D

    C++ Model of a charged particle in a magnetic field

    Homework Statement Im taking my first physics class and We have to do a research project. The project can be anything we want. I decided to make a c++ program to model a charged particle in a magnetic field. When I first researched the problem I't seemed straight forward enough. The force on a...
  40. J

    Comp Sci How Do You Correctly Implement a String Input Validation Loop in C++?

    Homework Statement I am writing a program which requires me to make and call a function: string Menu() This function will display a message to the user. It will then accept the user's choice (as a string) and check it for validity - that is did the user enter a "1", "2", "3", "4", "Q", or...
  41. Saladsamurai

    C/C++ C++ Text Geared Toward Physics Engines?

    Does anyone know of any good texts that are geared towards creating Physics Engines using c++? Or at the least, a text on creating physics engines in general? Any personal recommendations would be great.
  42. M

    C/C++ Java or C++ for Robot programmeng?

    Hi everyone! I am a mobile robot designer in autonomous space robotics. there is a great dilemma in front of me to opt a programming language for the robots between C++ and Java. the most important factor for me is performance of the language when i want to use it for applying very...
  43. M

    Comp Sci Next Perfect Squares for a Given Number

    Heres my problem, step one I've solved. Step two only ever returns the original newRoot*newRoo and I don't understand how to correct itTo demonstrate event controlled loops use arithmetic to create: 1.Create a sequence to determine the next largest perfect square 2.Create another sequence to...
  44. J

    Comp Sci C++ programming, Newtons Method.

    Having a lot of trouble the my C++ course, loops especially. This is the assignment giving me trouble The function you are to implement finds a root of the given function eff(x) using Newton's method. The given version of eff(x) implements f(x) = x2e-x-2 (where e is the base of the natual...
  45. T

    Comp Sci How Do You Assign Functions to Variables in C++?

    Hello everyone. I have an assignment that is asking me to find the roots using the bisection method. We are to find roots for two different functions. f(x) = x3 + 3x - 1 and g(x) = x3 - 2sin(x) I was wondering if there is any way to assign these functions to the variables f and g...
  46. J

    Comp Sci Why Is My C++ Program Outputting Zeroes Instead of Averages?

    Homework Statement I am in a beginner c++ class and this is my second program. I am having trouble getting the calculations to output correctly. I'm not sure what I'm doing wrong here, maybe somebody can help. Homework Equations The program takes user input data for points in a...
  47. M

    Comp Sci C++ identifying a palindrome (output error)

    I had a homework assignment that wanted me to write a function that would determine whether a five digit integer was a palindrome or not When I run the program I enter the palindrome there is no output for my if/else statement. What did I do wrong? Code Below #include <iostream> using...
  48. A

    C/C++ What program do you use to program using C++ or website design or anything

    So I want to learn C++ & website making as a side hobby since I have some free time in my days. What programs do you all use and would suggest for C++, Visual C++ ? LOL. And for website design or making; what program? Sorry I don't know the correct terms.
  49. E

    Comp Sci Implement Polynom in C++ w/o Linked List

    Hi, I need to implement polynoms in c++. I thought of doing this with lined list,i am not alowed using c++ linked list, so i will built it myself. I started thinking of adding and substructing, should i first sort the polynoms i want to sum by its exponents? (in this case it will be easerear...
  50. Z

    C/C++ Learning C++ by reading the code of open source projects?

    learning C++ by reading the code of open source projects? Is there any resource that teaches C++ by taking an open source project (at the level of quake 3 for example)and explains the code step by step for some one who only knows the very basics . In my opinion It will be very efficient . I can...
Back
Top