C/C++ Thread

....Don't try to scare people away from something they want to learn. If you find a beginner's book to C++, it'll go over the basics of what a variable is, what a function is, what syntax is, etc. The thing that really makes C++ harder to deal with is the memory management, but in the beginning that's barely something to worry about.
Seriously. C++ is a great language to learn. If you get comfortable with it first, then learning other languages will be vary simple.

I would suggest learning java possibly first, thought. It's syntax is very similar to C++ (just different keywords) BUt you don't have to worry so much about memory management. There is also a compiler for java called "BlueJ" It makes programming very simple so you can focus on getting your syntax right and developing proper programming techniques. I recommend that as a good place to start.
 
LoL I am not trying to scare anyone haha!

I was just saying that the C++ is not that easy.Still if the book he has is good then it will be a lot easier.Only he has to be prepared for a lot of studying.

Anyway good luck ScotALot!
 
Any idea as to why this isn't working for me? I'm getting a squiggly underneath 'sqrt'.

Code:
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int x1;
	int x2;
	int y1;
	int y2;

	char choice = 'y';
	while (choice == 'y')
	{
		cin >> x1;
		cin >> x2;
		cin >> y1;
		cin >> y2;

		cout << sqrt((x1-y1)^2 + (x2-y2)^2);
		cin >> choice;
	}
	return 0;
}
EDIT: Got it, change int to double. but now, when i try to run it, it says cannot find the path specified. help???
 
Last edited:
Any idea as to why this isn't working for me? I'm getting a squiggly underneath 'sqrt'.

Code:
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int x1;
	int x2;
	int y1;
	int y2;

	char choice = 'y';
	while (choice == 'y')
	{
		cin >> x1;
		cin >> x2;
		cin >> y1;
		cin >> y2;

		cout << sqrt((x1-y1)^2 + (x2-y2)^2);
		cin >> choice;
	}
	return 0;
}
EDIT: Got it, change int to double. but now, when i try to run it, it says cannot find the path specified. help???

I could be wrong but I thing its

#include "math.h"
 
would changing this make it find the path specified?

Well, yeah, if you don't have the syntax correct, it won't properly register the import statement and won't import the math class.

It's been a while since I've used C++. I just remember using <> for standard libraries and " " for anything that ended in .h, haha

also, if you could be more specific with the error. I'm not quite sure what can't be specified
 
Well, yeah, if you don't have the syntax correct, it won't properly register the import statement and won't import the math class.

It's been a while since I've used C++. I just remember using <> for standard libraries and " " for anything that ended in .h, haha

also, if you could be more specific with the error. I'm not quite sure what can't be specified

include "math.h" should also work.
Mainly double quotes are used to include custom header files, but it also works for the standard header files.
Just make sure that you have the math.h header file in the proper directory.
But it might be a compiler thing, so just to be safe try <math.h>
 
When i press ctrl+F5, prompt comes up and says 'Cannot find path specified, press any key to continue......'

Hey, I'm a fourteen year old in a town with a population of like 1000. I'm allowed to make some stupid mistakes. :D
 
Last edited:
When i press ctrl+F5, prompt comes up and says 'Cannot find path specified, press any key to continue......'

Hey, I'm a fourteen year old in a town with a population of like 1000. I'm allowed to make some stupid mistakes. :D

What compiler are you using?
 
You should be using just cmath (without .h) instead of math.h. The .h headers are there mainly for backward compatibility with C as well as older pre-namespaces C++ programs, these days you should try to avoid using standard headers with a .h extension in your C++ programs (and I mean only standard headers, for libraries and your own header files it's still customary to use the extension).
 
problem.jpg


This will probably help.
 
That's beyond weird. I can't think of any reason it would do that other than either you're actually missing some standard header files (in which case I would reinstall, you could be missing all sorts of things) or some really tricky project setting that I don't know of gone wrong.

Though I notice you hadn't saved the file in that screenshot... I don't use Visual C++ myself so I don't know for sure but some IDEs (at least in the past) don't compile modified files unless you've actually saved them; making a change and simply recompiling would cause the old source to be compiled.
 
My first step would be simply removing and installing VS. I will tell you, if you are in school Microsoft offers the full version of Visual Studio. Not sure, if that's what you have or not, but yeah, that's an option.
 
Though I notice you hadn't saved the file in that screenshot... I don't use Visual C++ myself so I don't know for sure but some IDEs (at least in the past) don't compile modified files unless you've actually saved them; making a change and simply recompiling would cause the old source to be compiled.

I believe that CTRL + F5 saves it and compiles it. but thanks for all the help, I'll reinstall it once my internet cycle starts over. It has a 5 Gig cap, and its nearly done with.
 
From the picture you gave us,it seems like some of your project files are simply missing and that of course results in a project not working no matter how good the programming code is.Go into your project directory and make sure that all the files are there on their correct locations.

Also be sure that IDE and OS are not corrupted and that their files are not missing because if they do,that will also result in your projects not working correctly.

You can try 2 things before repairing an OS and IDE:

1. Click BUILD ---> REBUILD SOLUTION.If the OUTPUT window reports that everything has been built correctly and that nothing is skipped and that nothing has failed then click the DEBUG button and see if your project works correctly now.

2. Make new C++ project and carefully copy and paste your programming code into the newly created project and see if application is now working correctly.

If the result is the same after these 2 things,try writing a VERY simple line of code which shows a simple text such as HELLO.If even that doesn't work then something is definetely wrong with your IDE data or/and OS data.In that case repair or reinstall IDE or/and OS.

These things can happen for numerous reasons.6 years ago I had a similar problem in C#.The code I always used always worked and one day it gave me blank error and did not want to compile at all.At the end I found out it was a corrupted OS DLL file that was causing the problem and not me lol.Since most of the programming code functions rely on IDE or/and OS DLL data,if that DLL data is damaged or missing,your projects will simply not work correctly no matter how good the programming code written by you is.




Cheers!
 
So I started a module of lectures and labs on C this week, and I was wondering if anyone has any cool .c source codes that would be interesting to look at??

Also, it seems like this thread so far is mainly C++, any other people just starting to learn to program and starting with C??
 
Generally C is taught as a stepping point before moving on to C++. C still has it's uses though (embedded code is fun).

All I ever really did in C was some console programs do learn the basics of the language. We did mess with BGI for a bit and made nibbles, it's an old qbasic game if anyone remembers it.
 
Back
Top