gets(path1);
You can overrun your buffer with gets. Use fgets instead (or you can use cin.getline if you want to use the C++ standard library).
gets(path1);
You can overrun your buffer with gets. Use fgets instead (or you can use cin.getline if you want to use the C++ standard library).
Usually anything with Try in front of it in C# checks to see if the retrieval/conversion/etc. is valid so you can use the call in an if statement.
Since the bool is returned, the value is returned by reference in the second parameter (C# has the designation of "out" to indicate that the parameter will be given a value within the method call). You can modify ravenous's code slightly to attain the same features.
Take out the .h, that's the filename, you want to instantiate an object of type Form1. Application::Run(gcnew Form1());
I think Nick Evan has a steel-cased laptop with a Harley Davidson sticker on it and he uses it when takes a break from work to sit at a Dutch sidewalk cafe. He has a leather jacket with a patch on it that says "slechte ezel," (sorry, best I could do) and has one of those wristbands with the spikes.
Head First C# is a great introductory text that is very "active" and engaging (for people of any age group). There's a new edition for C# 4.0. There's not a lot of depth to it, but it covers a large chunk of the language and has some fun labs.
To make your code neater you can hit enter(just not in the middle of your strings), like:
cout<<"According to my calculations...if you were to buy..."
<<userinput[0]<<" cars for $"
<<userinput[1];
as the compiler will get rid of the whitespace.
The nice thing about cout is that you can simply keep giving it input without an "endl" or a "\n" and it will keep it on the same line.
cout<<"According...";
cout<<userinput[0];
cout<<" yada yada"
cout<<endl;
and it will be all on one line too. Experiment with it a little.
As far as your second problem, you probably have a second cpp file in your project called whatevermyprojnameis.cpp, which contains a main() by default. Go ahead and either omit that file from your project, or delete the code that's put in there by default.
There's NO NEED TO TYPE IN CAPS. We can hear you just fine. If you are working in C, this should probably be moved over there. I'll flag it for a mod.
I've seen the so-called obfuscators (google "C++ obfuscator") but I can't speak to their validity or effectiveness. A few I saw changed strings to their hex equivalent, but that will only get you so far.
Is there a connection string you don't want your end users to see? I think the nature of the data will define how it can best be hidden.
Using "register" is virtually pointless these days because those good folks that write compilers already have tons of optimizations that are working in your favor. I'm sure that someone who has a more intimate relationship with compilers can flesh that out a bit for you.
If you've never explored templates at all, this might be a good example to implement (I think that's what arkoenig was getting at, but I don't want to speak for him). I believe the STL uses a quicksort, so if you have a debugger that lets you step into the library code, you can take a look at it in action.
Under Project/Properties/ConfigurationProperties/Debugging/CommandArguments
I believe the switch is "-E" to preprocess but not compile.
Declare video2 as a private member variable of Form1.
I don't know the specifics between 2005 and 2008. If I were to hazard a guess, the compiler is the same or better at complying with the standards as versions increase (some of those issues discussed http://msdn.microsoft.com/en-us/library/x84h5b78(v=VS.80).aspx (drop down the menu to change versions)).
I don't want to speak to the differences because many of them are nuances, but you can always test your code with multiple compilers to see the real story.
Maybe what you're looking for is:
int* list = new int[Width][Height];
Did you try that in the compiler? It doesn't work. For a dynamic nthDimensional array you have to build it up.
[rows,columns]
int ** my2Darr = new int*[rows];
for (int i = 0;i<rows;i++)
my2Darr[i] = new int[columns]; //for each element of the row array, make a column array
By the way what compiler are you using?
I'm currently using the latest Dev C+=
I use VC++ 2008 and 2010 (Express Editions, someday I'll take out a mortgage and get the full Visual Studio) or Mingw (g++ 3.4.X which I know is outdated, I'm migrating to the 4.4.X). They all have their strengths and weaknesses.
Dev-C++ uses an even older version of Mingw, so you're better off with Code::Blocks, or another IDE, which comes with a newer version of the compiler.
#include <iomanip> // don't put .h on the header file <iomanip>.
#include <conio.h> // you forgot to include
You are correct about the first one, but this OP is using an older compiler which was out before the header files were established as having no .h
However, conio.h is also a vestige. There's no need to use it, as it's non-portable. There are standard ways to emulate getche() like with a cin.ignore()/cin.get() combination (or flushing the input buffer instead of cin.ignore(), see http://www.daniweb.com/forums/post438070.html#post438070)
Okay, you're on the right track. MasterG has edited his post (please don't give the answer away, it doesn't help the OP at all), so see if you can figure out what you need to do with the parameter.
Hint: use a bool variable to keep track of whether you've been upset before. Check whether or not b is zero OR the bool variable is set to true.
As an aside: never use gets. You can input as many characters as you want, regardless of the size of the buffer, potentially knocking a hole into another part of your program.
I had flagged this yesterday to go into C (as the only Cplusplussy thing about it is the using namespace std;
.
Can you be more specific about what functions it is skipping?
It's the best idea for the sake of portability to use a compiler that adheres as closely to the standard as possible. Turbo C/C++ does not (as it arrived prior to the ISO standard, which was established in 1998). Turbo C/C++ can be a 16 bit compiler (I don't remember which version is) which among other things means that you are restricted to a smaller memory model.
Along with Visual C++ (one of the more recent implementations) there is the Gnu Compiler Collection, which includes g++ to compile C++ (or the equivalent mingw port for Windows)
(3000) - ignore just a counter
the context isn't clear
I don't fully understand what you mean by that.
I keep getting errors
What are they?
Line 30 is definitely not correct, you do not need the datatype when calling the function, just the parameters that you are passing to it.
There's a compiler flag you can set for C in Visual Studio. Go to Project/Properties/ConfigurationProperties/CC++/Advanced/CompileAs, and switch to C.
For certain, you don't need the semicolons after the if statement on 48,50, etc., just the one after return 0;
The reason the identifiers are undeclared is that you are compiling the code as C89 code, which requires all variables to be declared at the top of a block.
If you'd rather this be in C, hit the "Flag Bad Post" button underneath your name and ask a moderator to do so.
No, not a silly question at all. In your Form1.h, look about halfway down and you'll see the event handler "hookup" with the click event for each:
// button1
//
this->button1->Location = System::Drawing::Point(433, 290);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
Use whatever method you want in the &Form1::button1_Click portion (it has to be a function with the same prototype as the click handler, that is with the object, EventArgs signature). Any one of your _Click methods will do. So say you had:
private: System::Void AllButtons_Click(System::Object^ sender, System::EventArgs^ e) {
//yada yada
}
You'd go through each of your buttons and change the last line of each of them to this->button1->Click += gcnew System::EventHandler(this, &Form1::AllButtons_Click);
erasing the old buttonN_Click name.
The loop structure doesn't work because these methods are not meant to be invoked, but to respond to a event that happens in the window.
main() returns an int, always. main() returns to the calling system (usually the OS), so there's no point in returning your price value that way. If you must use those ancient headers it's stdlib.h
Line 26 has no meaning, especially since you have already outputted your result. Move that calculation back into your function. Think of a function just like one in math, you plug in something and you get something back out. You want to put in the price and markup and get back the price.
P.S. I know you are just starting out, but it never hurts to refresh your reading in whatever text that you have. The more (good) code you read and can emulate, the better you will become.
Yes, use an int array as an accumulator:
0xFFFF = 15+240+ ...
= [_|_|_|...|_|1|5]+[_|_|_|...|2|4|0] + ... = [_|_|_|...|2|5|5] + ...
Summing each new calculation into your array (you don't need more than one, just make sure you have things lined up and do the carries properly. This way you increase your capacity dramatically.
You're close - you need cin.getline()
(you have the parameters basically correct) to take in the whole line.
Try the following test program to see if it helps you understand the other part of the problem:
char x = 'a';
char y = 'd';
char z = '9';
std::cout << y - x<<std::endl;
std::cout << ++y <<std::endl;
std::cout << z - '0' <<std::endl;
Test different values of the letters and look at http://web.cs.mun.ca/~michael/c/ascii-table.html for reference.
What is your first name? Jim Bob
What is your last name? What letter grade do you deserve? C
What is your age? 100
Name: Jim, Bob
Grade: C
Age: 100
It's not working fine when I enter a first name with a space, it skips over the last name prompt completely. Hint, you can't use cin when you have a space as it uses a space as a marker to stop taking in characters.
WaltP has given you an important clue. First you need to modify your array approach, as it's unnecessary. Take in a regular char. A char is a 1-byte integer, and therefore you can perform arithmetic on it.
Did you read what I wrote? Start your own thread, post a section of your code. No one can help you if they don't have a context for it.
sam33, please start your own thread for this, and post a small block of code (with code tags) that includes that function call.
You need to reset the counter on or about line 36. Otherwise you are just skipping your while loop each time (you will want to reset your counts around the same point).
Minor point, but int should be unsigned on line 26.
have an empty mailbox once more
Or sponsor for a larger message quota. :) (Where's my commission, Dani?)
I thought she meant her own personal email, Happy, but maybe not.
Here's a sample that moves a circle around the window when you press the button.
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
//get this event from the right hand side of the screen in the form design
// window, click on the the lightening bolt and double click the cell next to
//the Paint()
Graphics ^ g = e->Graphics; //get the graphics handle from the form
Random ^ rand = gcnew Random(); //random number generator
g->DrawEllipse(gcnew Pen(Color::Black),
Rectangle(rand->Next(0,ClientRectangle.Height),rand
->Next(0,ClientRectangle.Width),10,10)); //make a circle in a 10x10 box at some
//point over the window (box has upper left hand corner coordinate specified).
//Sometimes it overlaps off the screen, but you get the idea
//this normally requires a handle to a RectangleF (a rectangle with float coords), but this is an overload.
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
Invalidate(); //forces Paint() event to be called
}
(the lines are too long so it looks like hell, but you get the idea).
See if that gets you started in the right direction and you can start translating the Bob Powell tutorial (or one of your choosing) into C++. That graphics object holds all of the methods (drawellipse, fillellipse,etc.). The graphics object only comes from the Paint method, so you'll have to use Invalidate() in your other methods to control it.
Finally, here is my question ***My e-mail In-box is full of Dani-Webs, not the Dani-Web In-box. I'm almost at maximum capacity. Without deleting these Dani-Webs or unsubscribing to them; how do I keep them without going over the maximum capacity?*** I created a special folder for this, but have the same problem.
That totally depends on what email program you use. There's usually a way to save to a folder locally or export some messages as text.
I see now, it's just a matter of keeping track of the post number to collapse/expand post.
Removing the post number forces the quote to be expanded all of the time (for us curmudgeons that liked that as the default). Simply quoting the text translates it to the box that can expand or contract.
You could overload the < and > operators for your class (which simply compare the prices of two different items)
See: http://www.learncpp.com/cpp-tutorial/94-overloading-the-comparison-operators/
>>lblName->Click += gcnew System
You do NOT use += in that line, just =.
No disrespect, AD, but it is correct. += is overloaded for events (which are really delegates in disguise) so that you can chain more than one event handler to a single event.
See http://www.functionx.com/vccli/general/events.htm (about 3/4 of the way down the page)
Add this to the ways that .NET has tried to corrupt our peaceful C++ lives.
You could use .find() - see the examples at http://www.cplusplus.com/reference/string/string/find/ (there's an overload for a character to be matched)
I took entire courses on code tags and forum posting :) I'm not an IT Pro, but I play one on TV.
noparse is just another tag that says, don't translate any of the tags that are in between the noparse tags, so you can type something like "please use [noparse][code] code tags [/code] [/noparse]" It's a handy trick.
You can't post something with just a quote. Let the system do the work for you, as you can always experiment and edit your post afterwards.
New members won't know what "inline code" is. IMO the entire explanation for [ICODE] tags should be removed in the read me's, to keep it nice and simple for newbies.
Also, I don't know how many times I've seen people frame code as [code] [/icode]
, which makes an unformatted mess, so I agree it's confusing as it is.
To post quotes as automatically expanded hit "Post Reply" and go to where it says "[QUOTE=happygeek;1408366]".
Just click where it says 'Click to Expand/Collapse' and the quote will, erm, expand or collapse.
Now delete the ";1408366" (or whatever the post number is)
Try instantiating a istringstream
istringstream iss(temp); //before line 7
if(!(iss >> e)) e = 0;
Thank you. That is exactly what I was looking for. I tried code::blocks and I like it. Maybe I give a try to Eclipse too. If I would ask you which one is better what would be the answer?
Yes.
I've never tried to use C::B with any other language, but Eclipse has plugins for darn near anything ever thought of in computing's history. I know that C::B has a lot of add-ins, but I have no experience with them. Both have integrated debugging support which is nice. I find Eclipse a bit more bloated and slow, but it's responsive once it fully starts. I'm sure other people will have their own opinions
My program is a graphical simulator under the allegro graphical library. Which one can fit better for the coding?
By the way, as the example with Dev-c++ showed it is important to choose the right tools for programming - what do you think about allegro? It is possible that it is not the best choice for graphics?
Check and see if there's an add-in. I'm not a graphics guy and I'm not really familiar with allegro beyond having played a couple of games that use it for the engine.
"nod" is declared in your constructor which means it is a local variable, and is destroyed once the constructor completes. Declare "nod" as a private member variable, and then you can initialize it in the constructor as you have.
Iam using gcc compiler: gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5). And it allows me to use such things. Ok. i'll try now to use a constant.
Edit: tryed a constant - same sh**. Am, and have you noticed, that it is not the function which causes problems ? with this function everything is ok.
See my edit above. I don't want to speak for him, but I don't think that AD was saying this was the cause of the problem, but he was offering you some advice on your code.
For line 140, you want is_open()
for sure.
EDIT: Also, the g in seekg is for "get pointer," which belongs with ifstream only. The corresponding functions end in p for the ofstream. (see http://www.cplusplus.com/reference/iostream/ofstream/ midpage).
The first is a preprocessor directive, before the compiler compiles your code, it will go through and replace sum with 1. The second declares a variable in memory to hold that quantity. I'm sure it can be argued as to which is best, but the "const int" is probably more common in C++ (when it comes to numeric constants).
Your problem is in line 34. Say there are 10 students, so on the line before you set aside an array of 10 (which has indexes from 0 to 9).
So next you are trying to create an array at student[10].test, which doesn't exist.
You must have a loop going from 0 to numStudents and initialize all of the test arrays in a row.
"lastfile" and "lastFile" are two different identifiers
See your other post. It indicates a pure virtual function, which automatically designates your class as abstract.