1,288 Posted Topics
Re: As Schol says, help us to help you. What does your program do that you don't want it to; what does it not do that you think it should; what input do you type into the keyboard to demonstrate the bad behaviour; what output do you get on screen. | |
Re: Error codes are not universal. Those are error codes your compiler happens to use. Other compilers do things differently, so don't quote error codes; tell us what the actual error is. What are the errors, and on what lines are they? | |
Re: Could you change your while condition so that you don't stop when the queue is empty, but instead stop when `queue.size()` is one? | |
Re: ld is the programme that links your object files together. It's either been deleted, or you're looking in the wrong place for it. | |
Re: char year= "YYYY"; You're trying to create a char object here.A char object can hold ONE char. One. You're trying to somehow store "YYYY" in an object that can hold ONE char only. `year[] = "YYYY";` would do what you want. Likewise with month and day. | |
Re: Iterators aren't the same thing as pointers. Testing an iterator against NULL makes no sense. Typically, an iterator is tested for being beyond the range of the container by comparing it to the iterator returned with `end`, e.g. `if(s2 == str2->vec.end())` | |
Re: You don't need to initialise the variable `len1`. You set a value before you use it, so that's fine. I see that your main function returns on line 19, so line 20 and line 21 will never be executed. This seems silly. Your code compiles and runs fine. The only … | |
Re: Your function dateparse creates a char array named `year`, and then you set that to a string, somehow, and then you call c_str on it, even though it began life as a char array. Does this code even compile? | |
Re: Show us the code (and yes, fix the warnings - the ones about not every control path returning a value are actually pretty serious and even if it did build, it was broken, and you'd generated some kind of mutant frankencode). It is quite possible to write code that a … | |
Re: Let's start with the function getGrades. > -GetGrades function should get number of grades, read the grades entered, find the sum of those grades and pass the sum and number to FindAverage. The code you have for that function does this: Gets the number of grades. Uses the right shift … | |
Re: Do you know how to do this on paper? Do you understand what is meant by a number being in a base other than base 10? | |
Re: Turbo C++ was written for DOS, back in the early nineties. Are you running a PC from twenty years ago? If not, I suggest you instead use a modern compiler. This will have the advantage that you can use actual C++ instead of C++ from twenty years ago which a … | |
Re: I don't see you storing the grade in a char array. if ( score >= 92.0 ) { grade[i] = 'A'; } and so on. | |
Re: Line 17 AND line 19 are reading from file. Change line 17 to this: `while (inputFile >> hours && inputFile >> pay)` Remove line 19. | |
Re: If I had to guess, one of your character tests or manipulators (isupper, toupper, islower, etc) is failing an assertion because you're giving it bad input. | |
Re: How would you do it on paper? Serious question. Programming begins with thinking. Here is some code: int main() { std::cout << "Hello world"; } How do you know how to indent that? | |
Re: Looking at this code, it seems that `_ps` is a pointer to a string object. So this: `_ps->copy` is an attempt to use the string class function named `copy`. Here is the prototype of that function. `size_t copy (char* s, size_t len, size_t pos = 0) const;` So the first … | |
Re: We call them `string`s. #include <string> string someStringObject; | |
Re: How about a program containing a function that creates an array of structures and loops over it? | |
Re: Your first `for` loop is calculating lots of results, and throwing them away. You should calculate a results, and then output it, and then move on to the next result. | |
Re: On class functions, it is a promise that this function will not change any member variables of the object. There is an exception, and here is the next keyword for you; `mutable`. When a class member is declared mutable, it *can* be changed by a function with const on. The … | |
Re: The same way you make an array of anything. char nameOfStruct[20]; // This makes an array of 20 char objects struct exampleObject nameOfStruct[40]; // This makes an array of 40 exampleObjects | |
Re: How often does the industry sector in your part of the world ask people about their public code repositories? The last time I was looking for work (about seven monthes ago), only one of my six leads asked about it and when I told them I didn't have one, they … | |
Re: #include <iostream> int main() { std::cout << "2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97" << std::endl; } | |
Re: [CODE]#include "stdio.h" int main() { int i; for (i=0; i<4; i++) { switch(i){ case 0: printf("1\n"); break; case 1: printf("23\n"); break; case 2: printf("345\n"); break; case 3: printf("4567\n"); break; default: break;} } return 0; }[/CODE] | |
![]() | Re: As a general rule, processors access memory in chunks of a particular size (a "word"). A structure will be "padded" with unused memory so that the variables are aligned with these "words", making reading faster and simpler. If I had to guess, your structure actually looks like this in memory: … |
![]() | Re: Your `for` loop is always testing the same character; the first one. You are never changing the pointer, so `ptr` is always the pointing at the same place, so `*ptr` never changes. ![]() |
Re: > for some reason visual basic is not compiling it Visual Basic won't compile C++ code. Visual Basic is for working with Visual Basic code. To compile C++ code, you need a C++ compiler. | |
Re: `#include “allegro.h”` is not the same as `#include "allegro.h"` Did you copy and paste that code from somewhere? Somewhere where the `"` symbol is replaced with `”`? | |
Re: On line five you create an int named `n`, which could have any value. Any value at all. Could be anything. On line six, you try to use an object named `a`, which you have not yet created. Are you trying to create an array there? Here is hpow to … | |
Re: I think you're asking what happens in this case: someObject* giveMeAnObject() { someObject anInstance; return &anInstance; } So you get back a pointer to an object made inside the function, on the stack. What happens is the memory is now available for other use and you're left with a pointer … | |
Re: In your example, Cstring is a pointer to a char, and you need to work on what it's pointing at; not on the pointer. The operator += applied to a pointer carries out pointer arithmetic; the operator += applied to a C++ string carries out whatever functionality the C++ string … | |
Re: You've very nearly written all the code you need to answer those questions. #include <iostream> int main() { int number1 = 0; int number2 = 0; while(number1 < 5) { number1 ++; number2 += number1; } std::cout << "number1 = " << number1 << std::endl; std::cout << "number2 = " … | |
Re: No such compiler exists. All modern compilers use actual C++. The syntax isn't "changed"; it's "correct". If you want to write programs for MS-DOS in the year 1990, use Turbo C++ 3.0 If you want to write programs for a modern operating system, use a modern compiler (and use actual, … | |
Re: `include<conio.h>` Non-standard, very old, not supported by modern compilers. `void main(void)` Just plain wrong. C++ recognises `int main()` `clrscr();` Non-standard, see conio.h `scanf("%d",item);` You should be passing a POINTER to item Your `if` and `else` branches are incorrect, missing brackets and that sort of thing. `getche();` Non-standard, see conio.h | |
Re: Here is the method. 1) Write the program in a plain text file. People commonly name this something.cpp 2) Feed the plain text file to a compiler and then a linker. These give you an exectuable file. 3) Run that executable file. So you need to get a compiler, and … | |
Re: Off the top of my head, you need to set the port number in the SMTPClientSession constructor call, and I wonder if gmail requires any kind of login more sophisticated than the default unauthenticated login attempt you get with `smtp.login(); ` Here's some example code: http://axistasoft.com/blog/poco/item/sending-e-mail-messages-using-poco-smtpclientsession-class | |
Re: Without a lot, lot more information, no. What operating system? How are you creating the imagebox? How are you reading the video? | |
Re: You're set yourself a really good programing task here; it's simple to get something working, but there are many improvements and advances to be made from there. You need to think about how you would solve this on paper to start with. You've got a file, containing letters; you can … | |
Re: `stdprn` was a non-standard identifier provided by some very old DOS compilers. If you're not using a very old DOS system with something like Borland C from 1985, it won't work. | |
Re: Your class is named `salaried` in the header, but `Salaried` elsewhere. See the difference? | |
Re: The linker cannot find the function `TicketFineCalculator::TicketFineCalculator(int)` Something in your code is trying to call that function, and either it doesn't exist, or you haven't compiled the code containing it, or you have compiled it but the linker isn't being told about the compiled file. Start with the easiest possibilites; … | |
Re: This thread discusses it at length: http://www.cplusplus.com/forum/beginner/1988/ The first suggestion, to have std::cout << "Press ENTER to continue..."; std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' ); right before your ` return 0;` should be fine. This solution requires you to` #include <limits>` and `#include <iostream>`. There are many, many more solutions. | |
Re: `long int` is guaranteed not to be smaller than `int`; that's it. `long int` might be the same size as `int`, it might be bigger than `int`, it will not be smaller. In your system, it's the same size. On some systems, it might be bigger, so it could hold … | |
Re: http://www.cplusplus.com/doc/tutorial/basic_io/ I also suggest you help yourself out now and switch to using `string`s rather than naked char arrays. | |
Re: `while(o!=9);` Did you meant ot have that semi-colon? This code is the same as this: while(o!=9) { }; Your code will loop forever, doing nothing. Anyway, here is how to ask a question that will get an answer: Present the code. Tell us what you did (e.g. what you typed … | |
Re: None of those look like errors: `Cannot find or open the PDB file.` No debugging file for this. Normal. `Application "\??\C:\Windows\system32\cmd.exe" found in cache` You're trying to run cmd.exe through system, so that doesn't seem too surprising. `The program '[7592] Shutdown.exe' has exited with code 0 (0x0).` Code 0 usually … | |
Re: Typically, I use the following on the command line to get the name of the last modified file. `ls -ltr | grep ^- | tail -1 | awk '{ print $(NF) }'` To include files beginning with `.`, I use `ls -latr | grep ^- | tail -1 | awk … ![]() | |
Re: Where in your code is the cost of something added to the total? Also, it is a very bad idea to control program flow using `goto`. We have functions and control statements for that. | |
Re: You will be reading some numbers as strings, some strings as numbers, and you have no way of telling if you're meant to be reading a string or a number. You need to read every word as a string, examine it, and do whatever is appropriate if it's actually a … |
The End.