2,827 Posted Topics
Re: [QUOTE=Ancient Dragon;519038]The other file you need to write is the *.cpp file that implements the functions in that class, and main() which all standard C and C++ programs have to have. When you created that Dev-C++ project it already created the main.cpp and main() function shell. So now all you … | |
Re: It looks to me like you will get an out of scope error here (and other places): [code] void role::setGrade(int studentId, char grade) { for (int x=0; x < numStudents; x++) if (courseRole[x].getId() == studentId) break; if (x < numStudents) courseGrade[x] = grade; } [/code] Putting brackets in, this is … | |
Re: It can't. You have to tell it what it is. As you are reading it in from the text file, you know the text file's layout. You know when a student id is coming, so when it does, you read the data in to the appropriate variable which you have … | |
Re: I think you are close to your goal: [code] #include <iostream> using namespace std; int main() { int oddNum, num, oddCount = 0; cout << "enter an integer: " << endl; cin >> num; while (oddNum != 0 && num > 10) { num = num % 10; oddNum = … | |
Re: They're probably all posting over in Dream In Code where you have it posted too. | |
Re: Well as far as cleaning up the code you can change this: [code] cin >> note; if (note == 'a' || note == 'A'){ freq = 440;} else if (note == 'b' || note == 'B'){ freq = 494;} else if (note == 'c' || note == 'C'){ freq = … | |
Re: An overloaded function could be like this. You could have two functions with the same name but which take different parameters. For example, you could have a function called "calculate_balance" that takes no parameters and a function called "calculate_balance" that takes an integer, for example. Something like this: [code] void … | |
Re: Are you sure you want [code] int f (int & n) [/code] I get an error when I compile the above but I don't when I do this: [code] int f (int n) [/code] Does anybody else get an error? | |
Re: Visual C++ has a pretty good "calculator" example in the free examples that come with Visual C++, including the express version. You press buttons on the calculator and it displays them in the text box portion. It has an action listener for all the buttons. Expand it and you have … | |
Re: Looks like you have a set: {A,B} within another set: {{A,B},{B,C},{C,D}} within another set: {{{A,B},{B,C},{C,D}},{{A,C},{C,E},{E,F},{F,P}}} So you have a set of chars within a larger set within a larger set. Three levels of sets: So maybe three separate structs: [code] struct letterPair // bottom level { char firstLetter; char secondLetter; … | |
Re: You have a brackets issue: [code] do { System.out.println("Please guess a random number;"); z = stdIn.nextInt(); while(z != x) { if(z>x) { System.out.println("Too High. Guess Again:"); z = stdIn.nextInt(); } else if(z<x) { System.out.println("Too Low. Guess Again:"); z = stdIn.nextInt(); { // change to '}' to end "else if" code … | |
Re: Tomcat is also very finicky about shutting down and starting up. When something is not working the first thing I try is to shut it down then start it back up. It seems to refresh a lot of things, particularly if you recompile a java program. The last poster is … | |
Re: Chane this line: [code] num2 * num1 << " "; [/code] to this: [code] num2 * num1; [/code] and the numbers will line up. | |
Re: This works: [code] #include <stdio.h> #include <string> using namespace std; struct MyStruct { string IDname; int numbeOne; int numberTwo; }; void functionOne(MyStruct ArrayOfStruct[]); int main() { MyStruct RecArray[100]; functionOne(RecArray); return 0; } void functionOne(MyStruct ArrayOfStruct[]) { //function code } [/code] Your original function declaration did not match your actual function … | |
Re: Well, there is the "path" and there is the "classpath". Normally I adjust the path first, then write a little "Hello World" program in some directory like the Desktop and save the file as "HelloWorld.java". [code] // HelloWorld.java public class HelloWorld { public static void main (String[] args) { System.out.println("Hello … | |
Re: I made up a file called "text.txt" with a bunch of random characters in it and typed in: test text.txt ab on the command line and it ran "fine". I put "fine" in quotes because it ran without crashing and giving me any of the errors it gave you, but … | |
Re: Does he really need to have a database? You mean like setting up an SQL database or something, then inserting and querying from the C++ program using SQL commands? I guess we need more details, jmvr_danga_14. Is that what your boss/teacher is looking for? That seems like a larger undertaking … | |
Re: You're probably going past the bounds of what an integer can store and getting an overflow. An integer in a 32 bit system overflows at 2^31, I believe. It cannot hold anything higher than that. | |
Re: You can compare each character's ASCII value. If its ASCII value is in the range of 48 to 57, inclusive, it's a digit. If not, it isn't. That would be fewer comparisons than comparing the character to each of ten digits, which would take ten comparisons. The fact that you're … ![]() | |
Re: It looks to me like you are calling the function fnc with the exact same values every single time you call it so an infinite (till it crashes) loop makes sense since it's doing the same thing every time. You're passing fnc parameters x1 and x2, which never change. Do … | |
Re: There are a few ways to do it and you have two separate problems here. Problem 1 is creating the "golf" class with its functions, then successfully compile the "main" file and the "golf" file(s) and linking them so you can use the "golf" functions from "main". Problem 2 is … | |
![]() | Re: If you are running a "hello world" type console application and you are NOT running it from a command line but rather by double clicking a file from Windows Explorer or through an IDE like Dev C++, a console window opens, runs the program, then closes before you can see … |
Re: If you want to put aside a 2-dimensional array, you could do this: [code] char buffer1[1000][20]; [/code] This puts aside 20,000 bytes. But do you want 20,000 bytes? You said you are only storing bytes 500 - 1500, which is 1001 bytes. If you want to do a 2-D array … | |
Re: The difference between [code] int ErrMsg(ustring& ) [/code] which is what you have, and [code] int ErrMsg(ustring ) [/code] is that in the first function, the function is looking for a parameter that is "passed by reference". The second function is looking for a parameter that is "passed by value". … | |
Re: How 'bout this? [code] #include <string> #include <iostream> using namespace std; struct letteroccurence { char letter; int occurence; }; int main () { string letter_box; letteroccurence occurences[26]; // 26 letters in alphabet cout << "Please enter a sentence ending with a period: "; // will read in string until you … | |
Re: When you say you need to create a binary tree but not a binary search tree, do you mean that that there is no order to the tree? In other words, do you simply insert the next element into the tree without doing any comparison of the values of the … | |
![]() | Re: any one who can help me? hello,,im a Filipino student from Cabanatuan City Philippines.. Im just a Second year College student taking up Computer Science.. I would like to ask you something about sorting an alphanumeric character.. im just a student i would like to learn in advance programming.. can … ![]() |
The End.