1,288 Posted Topics
Re: Because you're using C linkage, you cannot create overloaded functions. There already is a function [B]CreateFile[/B], so you can't write another one. Rename your function [B]DLL int CreateFile(char *path)[/B]. | |
Re: Here is the first line of the function you actually wrote: [B]double enr(int no, int nc, double box, double x[][3], double c[][3])[/B] Here is what you thought you were trying to write, and what you're trying to call: [B]double enr(int, int, double, double, double);[/B] [B]double x[][3][/B] is [U]not[/U] the same … | |
Re: If you don't like to see the warnings, you can do this (although there's no problem with seeing warnings - the code will still compile): [url]http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/cc2488bf-9100-46a6-a2e0-968e5d5707fc[/url] The error on the end is in your code: [B]main()[/B] should be [B]int main()[/B] | |
Re: [QUOTE]char* dest = "2"; strcat (dest,to);[/QUOTE] You're trying to write over memory that isn't yours to write over. See that "2"? All the memory next to it that you're trying to write over isn't yours. When you use strcat to concatenate two C-style strings, it is up to you to … | |
Re: [B] const unsigned char x[4] = {1, 2, 3, 4};[/B] [url]http://ideone.com/EHqa1[/url] This works fine. I note that you're putting int values into char types; is that deliberate? | |
Re: [QUOTE]"void main" is not and never has been valid C[/QUOTE] Actually, the ISO C spec allows [B]void main()[/B] | |
Re: Well then it sounds like you want to run a script, or some kind of batch file. If I were using bash as my shell, the file I made would look something like this: [CODE]#! /bin/bash ./run inputFile1 inputFile2 inputFile3 ./run inputFile4 [/CODE] and so on, and then I would … | |
Re: Get all y2 values. Find largest. Get all y1 values. Find smallest. Subtract smallest y1 from largest y2. That's the number you're looking for. | |
Re: [B]void userInfo::setId(string anId) { id = anId;}[/B] What's id? Is that definitely a member of the userInfo class | |
Re: You've tried to define the Weapon type twice, once as a class and once as a struct. Pick one; class or struct. Not both. Your code is full of comparisons where you've used = instead of == You've screwed up the braces in the function [B]void Player::attack[/B] You've made some … | |
Re: You've screwed up your brackets and have some functions being defined within other functions. Fix brackets. | |
Re: You must [B]#include<string>[/B] to use the string class. C++ does not allow variable size array - you must make [B]maxn[/B] and [B]maxm[/B] const You must put a semi-colon on the end of [B]beolv("test.txt",n,m,x)[/B] | |
Re: Wait a minute, so you knew about [B]isdigit[/B] but you're too lazy to search for functions? If you're so lazy, why not use [B]isdigit[/B]? | |
Re: [QUOTE]I guess pointers are the most challenging part of C++, any help would be much appreciated.[/QUOTE] Pointers are fantastically simple and easy; they're just often badly taught using clumsy metaphors that do more harm than good. Anyway, here's some code that takes in as many names as you care to … | |
Re: [QUOTE] i dont understand were the wiz0-2.save[/QUOTE] That's not anywhere in your code. | |
Re: [B]marks[30];[/B] does not turn the [B]int[/B] marks into an array. If you want marks to be an array, make it one when you declare it. | |
Re: Please do not use Dev-C++. Here are some reasons why: [url]http://cplusplus.com/articles/36vU7k9E/[/url] | |
Re: [B]str.c_str()[/B] returns a char* you can use | |
Re: [B]srand[/B] does [U]not[/U] give you a random number. [B]srand[/B] is used to set the random number generator. Set it once, at the start of your programme, and after that when you want a random number use [B]rand[/B] [url]http://www.cplusplus.com/reference/clibrary/cstdlib/rand/[/url] | |
Re: [QUOTE]What is the purpose of function with nothing in the parentheses? Like this something()[/QUOTE] To do something where you need to provide no more input. The most obvious is a [B]default constructor[/B]. Any time you create an instance of an object more advanced that the most basic of plain data, … | |
Re: Have one controlling program that can start and kill the others with system calls such as fork() and execve(). | |
Re: [B]while(y!=1||y!=2);[/B] Can you imagine any value of y for which at least one side of the OR isn't true? The answer is no - if y=1, then the right hand side is true, so the whole OR statement is true. If y=2, then the left hand side is true, so … | |
Re: The easiest way to do this would be to just carry the entire OS on USB and boot from it. | |
Re: [B] return main();[/B] This makes no sense. It turns the program into a never-ending recursion that will eventually run out of stack and crash. Do not call [B]main()[/B] from within your program. | |
Re: As thines01 says, a better option is: [CODE]void account::deposit_checking(int n) { double a_20 = 20; if(n == 1) checking += a_20; }[/CODE] The rest of my post explains why your original version didn't work. [CODE]void account::deposit_checking(account d, int n) { double a_20 = 20; if(n == 1) d.checking += a_20; … | |
Re: Once I added <cstdlib> to the #includes so you could use [B]exit[/B], seemed fine. [B]A Telephone Directory Enter first name: John Enter last name: Mark Found!! First Name: John Last Name: Mark Telephone Number8888888885 Do you want to look for another? n Good Bye...[/B] | |
Re: Use as normal, and just ignore the data you don't want to use. [CODE]ifstream someStream("file.data"); std::string dataInput; someStream >> dataInput; someStream >> dataInput; someStream >> dataInput; // Now use this one[/CODE] Loops etc can do the heavy lifting. | |
Re: [QUOTE] is sorted in ascending order[/QUOTE] [CODE]for(int i=1;i<sizeOfArray;++i) { if (array[i]>array[i-1]) { //Looking good... } else { std::cout << "Not sorted :("; break; } }[/CODE] [QUOTE]from even to odd number or not ?[/QUOTE] I have no idea what you mean by this. | |
Re: Are you able to sample the mouse position periodically, creating a record of its location in a co-ordinate notation of some kind? That's how to start. | |
Re: In the [B]for[/B] loop you set a=1, but you don't in the [B]while[/B] loop. | |
Re: You appear to be writing your code in Visual Basic, but then you're trying to compile is as if it were C++. They're two different languages - a C++ compiler will not be able to turn your Visual Basic code into a program. | |
Re: I'm talking here just about your second program. [CODE]PoolSize(float Length, float Width, float Depth, float volume, const float cubicfeet=7.48051948);[/CODE] This is not how you call a function. You don't specify what kind of object they are when you call it. Just the name. Try [CODE]PoolSize( Length, Width, Depth, volume, cubicfeet);[/CODE] … | |
Re: Build your code with debug symbols in. Run it again in gdb, and when the segFault happens, enter [B]up[/B] until you're in one of your lines of code. Enter [B]print variableName[/B] for each variable in that line of code until you find the bad one. Almost certainly, one of your … | |
Re: If you mean files (a file system is something quite different), this is dependent on your operating system and the libraries/API that you've got access to. What operating system are you using? | |
Re: [QUOTE]I have already tried to add (int *) to the beginning of the codes but didn't work.[/QUOTE] Explicit conversion is what's required and should work. Show us how you did that. | |
Re: [B]I have deleted pInt[/B] This means "I have told the operating system that I don't care what it does with the memory pInt is pointing to". That's all it means. pInt still exists, pInt still contains the same memory address, and frequently that memory will contain the exact same values, … | |
Re: You're missing a [B];[/B] at the end of that. See each one of those function? This list: [B]BankAccount(); BankAccount(string,double,string); string getID(); double getBalance(); void setID(string); void setPassword(string); bool deposit(double); bool withdrawal(double); void addInterest(); bool equals(BankAccount); string getPassword();[/B] You need to make each one of those. I'll get you started, and … | |
Re: The find_last_of function takes more than one parameter. You're trying to feed it just one parameter. Here are the find_last_of functions. Pick one. [url]http://www.cplusplus.com/reference/string/string/find_last_of/[/url] | |
Re: [QUOTE]char experiment = 'Q' is what I got, however if I were to type in "AAA" or simply more letters than one then it[/QUOTE] experiment in your example above is a single char. Is it any wonder that trying to put more than one char into it causes problems? There … | |
Re: You set the value of x to zero at the start of your loop, and your loop will end when x does not equal zero. Given that you don't change the value of x, when do you expect the loop to stop? (Never) Have you mixed up the variable [B]value[/B] … | |
Re: A class is a kind of object. You create one, and then use it. Like this, for example: [CODE]int x; // make an object of kind int, named x char y; // make an object of kind char, named y String z; // make an object of kind String, named … | |
Re: The question is actually why [I]wouldn't[/I] your programmes disappear when they're finished? What are you doing to keep them visible? Nothing. Your programme is a console programme; when you run it, a console is brought into existence. When the programme finishes, the console closes. If you open a console yourself … | |
Re: [url]http://www.cplusplus.com/doc/tutorial/files/[/url] | |
Re: Are you forced to use an array? This would all be much easier if you used a proper C++ container type such as vector. | |
Re: Your deletion mechanism essentially writes over location i with location i+1. What happens when you get to the highest member of your array? [B]stdRec[i].studentID = stdRec[i+1].studentID;[/B] If [B]i[/B] is the last member of the array, you are then trying to read [B]i+1[/B] - this is not your memory to read. … | |
Re: You are calculating one int divided by another. In C++, dividing one int by another will return an int. So, for example, 5/2 = 2, and 3/4 = 0. If you want the output to not be an integer, don't divide one integer by another. One way to achieve this … | |
Re: I suspect you're creating the stack using the wrong syntax. May we see the line of code in which you try to create the stack? | |
Re: Work out how many quarters are in the amount of change. Display number of quarters. Subtract (0.25 * number of quarters) from amount of change. Repeat for dimes. Repeat for nickels. Repeat for pennies. |
The End.