Beginners - September 2016 (Page 3)

Array
 
1.Rewrite the program on cumulative final grade. This time: a. use rectangular arrays. b. Use array for student name which are also inputted during runtime. c....
[5 replies] Last: Line 16: sn is undefined. Since you can calculate grades for 5 stud... (by AbstractionAnon)
Function uses like this
 
Hey guys so I've been wondering why don't people do this all the time: #include <iostream> template<class T> void print(T out) { std::cout << out; } in...
[2 replies] Last: Thanks for the great answer! I also do this when I'm testing out my p... (by boost lexical cast)
Review HW Code If I can make it simpler?
 
I believed I did this correctly. But I have the tendency to over think things. Just wanted to know if there are things I can make any simpler or cut down on cod...
[7 replies] Last: For studying purpose, there is no problem with using namespace std; .... (by SakurasouBusters)
I don't understand: "friend std::ostream & operator<<(std::ostream & out, const Hour & h);"
 
I have to define methods of a given class: Hour.h ... class Hour{ public: Hour(); friend std::ostream & operator<<(std::ostream & out, const Hour & ...
[2 replies] Last: > I'm not sure what ostream is or why he's needed. https://msdn.micros... (by mpark4656)
Build Error from changing cout string
 
I'm not even sure I stated the title right. I just started a tutorial series to learn C++. I'm using eclipse and mingw. I typed out this simple code and built t...
[10 replies] Last: Lol ok. Thanks. (by sakers288)
If the age is between...
 
Hello everyone. I need help putting "if age is between 17 and 42" in code form. I know what to put for the output if the age is between those two int. Right...
[1 reply] : if(age >= 17 && age <= 42) { // Do something... } (by SakurasouBusters)
Data type conversion int to double within function
 
I'm in my first programming class and am having a little trouble understanding what I should do. I extracted the trouble shooting problem from my actual assignm...
[7 replies] Last: Lets say that you have thousand files in your program code and million... (by keskiverto)
Getting part of string in CSV file and converting to int
 
I'm trying to do math with some of the information in two different CSV files, using C++. Right now I'm only working with one of them, and I want to find out ho...
[3 replies] Last: think about vfscanf to analyze and transform the line ReadStuff ( p... (by CptJY)
I want my entire program to run again but my loop is won't work the way intend it to
 
Hi! :D program runs but one problem is the loop, what i want is for the entire program to run again but apparently only the statement "Do you want program to ru...
[6 replies] Last: Y is not 'Y' ! Y is as variable 'Y' is the caracter. Add single quote... (by CptJY)
read-only error with string
 
Maybe someone can help me with this. I reduced the code a bit: int main(){ //The main string to work with std::string workQ; //load the text file an...
[5 replies] Last: You could also replace the loop in your replace function with a ranged... (by jlb)
Print Spiral with 2d array
 
I'm currently working on an assignment where I'm supposed to create a spiral using a 2d array of ints. I currently have the programming fully working by normal ...
[4 replies] Last: I edited both so they work without any command line arguments. I do se... (by FredDilb)
Sentinel, Query, and Looping Control: Can't Compile
 
I'm working on an assignment for my class, but I can not get this app to run, because there are errors. This is supposed to be a math "game" that the user input...
[5 replies] Last: To anyone who finds this thread, this was my problem: I had an extra ... (by CobaltThunder)
tokenizing issue
 
I am writing a program for class which takes an expression as input and then prints out the numbers in the expression and the symbols from the expression in ord...
[6 replies] Last: Thanks krako! Looks like stringstream was the way to go. (by hornet7288)
Returning a pointer to dynamically allocated memory from a function
 
I need to dynamically allocate memory in a function and then return a pointer to it. Could someone verify if this is the correct way to do this and that it does...
[4 replies] Last: "duplicate" is a common non-standard function called strdup() . https... (by Duthomhas)
Help with command line
 
I'm trying to pass argv to a function but since I have argv defined as char* it will not let me as the function asks for a double variable. Is it possible for...
[2 replies] Last: Thank you! (by chocoluve)
command-line argument error
 
Write your question here. My code is giving me the error "a function definition is not allowed here before the '{' token. I'm thinking it is because of the argu...
[2 replies] Last: sigh thanks mate (by chocoluve)
looping in array with class names
 
I'm trying to use a loop to load an array from a file with strings and ints. Additionally while it is loading into the array I would like it to set the class n...
[2 replies] Last: line of string (first name) line of string (last name) int (year) int ... (by nyork3415)
Floor function
 
Hey guys, trying to write a program using the floor function that outputs a whole integer, rounded to the tenths, rounded to the hundredths, and finally rounded...
[3 replies] Last: Hello my2jlw3s, During my dinner break I realized that rounding to th... (by Handy Andy)
by mmcro
Unable to return value from while loop/Issue with array
 
I need to find the amount of digits that make up a user inputted value. I then need to use that number to declare an appropriate size array. (Not allowed to use...
[1 reply] : int getDigit(int num) //This function finds how many digits are i... (by SamuelAdams)
C++ program to read n numbers and print the second largest number
 
Is this correct? #include <iostream> using namespace std; main( ) { int n, c; float v, l = 0.0, s = 0.0; cout << "SECOND LARGEST NUMBER of n val...
[3 replies] Last: 1. Read 'n' numbers: while (std::cin >> n) [CTRL-Z] to stop reading 2.... (by Boilerplate)
September 2016 Pages: 12345... 34
  Archived months: [aug2016] [oct2016]

This is an archived page. To post a new message, go to the current page.