Was C++ hard for you?

I'm constantly struggling to get the homework done. It's not until a few weeks after the homework that I start to understand it. Are there easier languages than C++? I had python my first semester and I barely had problems at all.
closed account (o1vk4iN6)
I don't know if it was hard to learn, but there are a lot of pitfalls you can make if you don't know what the specification for that circumstance is. It does things usually a different way than you would naturally think it would do do to performance reasons.

What kind of problems are you having, maybe give an example code that you are currently not understanding ?
Last edited on
Well as of now, its using 2d arrays. I've already posted this

I'm supposed to use 2 2-dimensional arrays; 1 to read the persons name from a file, and the other to read the rest of the numbers. I haven't started the second array yet because i cant figure out the first one. I end up reading everything in instead of just the name.

The file looks like this:

johnson 45 53
taylor 34 12
etc
etc

When i read it in, i read in johnson 45 53 when i only want to read in johnson. I can only use character arrays not strings

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
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <conio.h>
#include <fstream>

using namespace std;

int readfile();

int main()
{
	readfile();
	_getch();
}

int readfile()
{
	const int ROW = 50, CLM = 500;

	char name[ROW][CLM];

	ifstream inFile;

	inFile.open("p1data.txt");

	if (!inFile)
	{
		cout << "Cannot open input file. "
			 << "Program terminates." << endl;
		return 0;
	}
	else
		cout << "Open Successful";

	for (int i = 0; i < ROW; i++)
	{
		inFile.getline(name[i], CLM, '\t');
		cout << "\n\n" << name[i];

		
	}
	
}
It is fairly well explained which path you need to look in to here:
http://www.cplusplus.com/forum/beginner/109860/#msg599435
Topic archived. No new replies allowed.