edited 1×, last 20.07.10 11:08:29 pm
Forum
Off Topic C++ TutorialI don't really see the point in learning java tho, i'd say c ( or c++, c#) is better to learn.
Also, it's quite hard to fully understand programming ( doesn't matter if it's java or c++) in 2 months. It takes quite a lot of time to be honest.
YellowBanana has written
Big Java, pm me for a link
why so complicated? I hope that you're not sharing commercial ebooks or other illegal stuff via pm. this would be a crucial rule violation.
and if it's not illegal: why don't you post the link right here in the thread so people can see it?
Edit:
I plan once I understand Java to download Java 3D and create 3d games with java would java be a good language for games?
edited 1×, last 20.07.10 06:27:26 am
biggest problem I see with that is that the 3D engines for java don't seem to be as powerful as engines for c/c++. you shouldn't expect to get high-end state of the art 3D graphics. I didn't tried it myself though. just judging from videos/demos I saw.
@DC: I downloaded a few games, and watch a vid. I think your right, but isn't a C++ compiler a few thousand dollars? That is what I heard. Is C++ structured?
You should use mingw32 and Dev-C++ if you are using windows or maybe cygwin and Dev-C++.
Edit:
Know any good IDEs (C++)?
I guess I will need a tut at least until I get another book. I would google for my self but I don't know that I would get a good tut.
Don't expect C++ to be as easy as java though, you will prefer to do some things by yourself instead of using the standard libraries (ie: Reinventing the wheel) because including too many of those will result in a huge executable
You will surely need some references and tuts:
http://www.cplusplus.com/
http://www.cprogramming.com/tutorial.html
http://www.cppgameprogramming.com/ <-There we have a forum and some cool tutorials also, I'm a moderator
Anyways, I'd suggest that you start with Java unless you're actually interested in learning the lower level galores (or gores) of programming. To be honest, most of the features in C++ will look like bugs to the untrained eye, and it takes a hell of a lot of patience for someone starting with the language to actually progress unless you're familiar with most of the programming paradigms at a higher level or are well versed in the many theorems of logic and discrete mathematics.
And of course, the entire discipline of dynamic languages are considered to be just so way out there that they ain't got nothing on nobody... that's where the Python, Ruby, Lua, Perl, and even Pascal guys are sitting at T_T
-Edit: Albeit if it's for game programming, if you're going with the OpenGL toolkit, C/C++'s implementation is considered by many to be native and all other implementations a derivative thereof, so you may be better off with finding documentation and tutorial (as Flacko pointed out above). And I haven't heard of many GL toolchains on Java except for Khronos, which is an unbelievable hassle to work with since it doesn't implement the traditional BEGIN ... END transaction model. But since by then programming techniques should be secondary to the thought process itself, I suggest that you begin with learning about the general concepts of programming with Java and work your way down to C++, which in some ways of speaking, syntactically similar to Java.
Why does this crash.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream> #include <fstream> #include <string> #include <new> using namespace std; string* file_data; int filelc(0); int main() { 	file_data = new (nothrow) string[0]; 	ifstream file ("text.txt"); 	if ( file.is_open() ) 	{ 	 int i = 0; 	 while (! file.eof() ) 	 { 	 		getline(file, file_data[i]); 			i++; 			filelc = i; 		} 		file.close(); 	} 	else cout << "Error: Can not open file."; 	int l; 	for ( l = 0; l < filelc; l++ ) 		cout << file_data[l] << endl; 	while ( true ){ 	}	 	return 0; }
edited 6×, last 21.07.10 09:24:38 am
You initialized file_data into a size 0 container for string
2. getline(file, file_data[i]);
file.getline(buffer, size); - Where buffer holds reference to an initialized char array of length greater than size.
3. while ( true ){}
infinite loop...
The following is the equivalent of what I think you wanted to do:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream> #include <fstream> #include <sstream> using namespace std; int main() { 	stringstream data; 	ifstream file ("doubles.txt"); 	if (file.is_open()){ 	 while (!file.eof()) 		 data << (char) file.get(); 	 file.close(); 	} 	else cout << "Error: Can not open file."; 	cout << data.str() << endl; 	return 0; }
The following splits a file by line, no matter how many characters are in a line:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { 	stringstream data; 	vector<string> container; 	ifstream file ("doubles.txt"); 	if (file.is_open()){ 		char cur; 		while (!file.eof()){ 			cur = file.get(); 			data << cur; 			if(cur=='\n'){ 				container.push_back(data.str()); 				data.str(""); 			} 		} 		file.close(); 	} 	else cout << "Error: Can not open file."; 	for(int i=0;i<container.size();i++) 		cout << container[i] << endl; 	return 0; }
For larger files, use the getline(&char, buf_size) equivalent and check for the last char. You can also implement a native container but it's a little trickier and you need to be familiar with C/C++'s memory allocation mechanisms that is apparently considered "ugly" by the C++ camp (in favor of the default new and delete constructors which are basically just layered on top of malloc and free).
edited 1×, last 21.07.10 01:25:34 pm
-GaS- has written
I've heard allot of C#, apparently it's better than C++ but I'm not sure, what do you guys think about it?
I think that a Microsoft propietary language is not better than C++
Btw DB: It seems like I'm a bit late to answer your question
With c# it's much easier to write big programs, GUI and to use stuff like Silverlight.
C# is pretty equivalent to JAVA, except that it uses the .NET framework. I've written a few programs for Cs2d in C# ( like the RCON tool which u can find under files/misc.)
Thanks I mostly just wanted to store each line of a file in dynamic memory.
Edit:
the reason for the infinite loop is so that I can see the output.