Hey everyone, I'm new at visual c++ and MFC Applications, and so I am going through Ivor Horton's Beginning Visual C++ 2010 to make a drawing application through Microsoft Foundation Class. I added menu bars for options, such as shape(rectangle, line, and ellipse) and select colors (black, red, blue green). I have added message handlers to the program that makes it so that you can select different menu options like rectangle & blue, or ellipse & black. And I am at the point where the drawer can click LButtonDown to set the first point and the LButtonUp to release the …

Member Avatar
Member Avatar
+0 forum 2

Hey everyone, I have to manipulate two functions RECURSIVELY, strlen and strcpy. I was able to code the strlen: [CODE]int length(char* str){ if(str == NULL){ return 0; }else{ return length(str, 0); } } int length(char* str, int l){ int len=0; if(str[l]){ len = length(str,l+1); } else { return l; } return len; }[/CODE] But I am having a lot of trouble with even beginning the strcpy function: [CODE]char copy(char* old_str, char* new_str){ if(old_str == NULL){ cout << "Could not copy, string is empty\n"; return -1; }else{ } }[/CODE] Here is my input on Strcpy: - The base case can return …

Member Avatar
Member Avatar
+0 forum 7

Hey everyone, In my COMP 208 class, I was asked to do the following: "Redo Lab 2 Problem 2, only this time use vectors to hold the names and gpa’s instead of arrays. So you will work with 2 vectors, one holding the gpa’s (type double) and the other holding the names (type string)." THIS IS THE PROBLEM I NEED TO CONVERT TO VECTORS: "Your program sorts the students ascending by gpa, and prints the sorted list including names. To keep the names with the numbers use parallel arrays, one for the names, the other for the numbers. Sort the …

Member Avatar
Member Avatar
+0 forum 6

The question is: A file contains a list of names in the form: Jones, Frederick M Brennan, Claire Your program should alphabetize the list. Use the C++ string class. Also, extract names from the input stream with getline(). What i know so far: main() should declare a char array and to open a requested file from the user extractNames() should print out what file is being alphabetized and use cin.getline() to stream in the file into my char array, line by line. swapNames() should use a sorting method, maybe bubble sort, to pass in the char array as an int …

Member Avatar
Member Avatar
+0 forum 3

Hey everyone, I need to write a program that reads names and GPA’s from a text file. The file looks like: James 3.9 Margaret 3.5 Charles 1.2 Jennifer 4.0 The program sorts the students ascending by gpa, and prints the sorted list including names. To keep the names with the numbers use parallel arrays, one for the names, the other for the numbers. Sort the numbers. Whenever you swap 2 numbers also swap their matching names in the names array. The only thing that I've done so far is to open the text file and created a function called: [INDENT][/INDENT]gpa_sorter(istream& …

Member Avatar
Member Avatar
+0 forum 10

Hey guys, This is only my second thread on DaniWeb and I am a beginner programmer. My code looks like this: (really easy to understand and shouldn't need any further explanation besides the fact that I need help understanding why when i give an answer related to the 'else' loop, it says what is needed, but gets stuck in an infinite loop!) [code] #include <iostream> #include <string> using namespace std; int main() { char answer; cout << "do you think megan fox is hot? <y/n> "<<endl; cin>>answer; do { if (answer == 'y' || answer == 'Y') cout<<"You are the …

Member Avatar
Member Avatar
+0 forum 5

Hey guys, This is my first official post on DaniWeb :) I am new at programming in C++ using visual studios, and right now I am fooling around with storing user input into Arrays. I am having a problem with my code, using an array size of 3 to store the users input into the first 2 spots [0 and 1] and then making a calculation in the 3rd spot[2]. Here is my code: [CODE]#include <iostream> using namespace std; int main() { double userInput[3]; //array can only hold *3* elements cout<<"Enter the number of cars you wish to buy: "; …

Member Avatar
Member Avatar
+0 forum 4

The End.