The below is my idea(rough one) to proceed to design first towards implementation.

Create structure for first two data

struct StudentIndex
 int No_Of_students;
 int date;
 (int year;
 int month;
 int day;) 

Fill this structure by read (using fscanf())
first 2-character for no_of_Students as int
next string(8 character) for date (or read as 4-character for year, 2-char for month, 2-char for day)

fscanf(fp, "%d %s ", structInfo.No_Of_Students,;//Or separte it by year, month, day

Then create struture for studentInfo

struct studentInfo
 int student ID;
 int course_number;
 char *submission_date; or (sepate date for month, day, year);

Fill this structure after filled StudentIndex structure

fscanf(fp, "%d %d %s "", structInfo.Student_ID,structInfo.course_number, structInfo.submission_date);

Once these information is filled you can easily read each data.

Hi Deceptikon,
Below are my opinion. If posting code snippets for below topics wil be useful

  1. Some algorithm, its usage, its appolications with real time example right from the basic algorithms. Then it will be useful for beginners like us to go with some specific(standard) algorithms to implement codings.
  2. Data strutures - when data structure should use? what type of data structure can be use? where can we use data structure? how to use them? etc,.
  3. Memory management related code snippets

    Please keep up this good work.

    Thanks in advance.

Here is the final modified one.

#include <stdio.h>
#include <stdlib.h>

#define BUFFER 100000
#define LINE_BUFFER 200

int glineCount = 0;
typedef struct 
    float x, y, u, v;

// Function Declaration 
void open_vec_file(const char*, PIVPOINT* );

int main()
    char fn[] = "PP_B00001.txt";
    int i = 0;

    PIVPOINT *pivp = (PIVPOINT *)malloc(sizeof(BUFFER));

    open_vec_file(fn, pivp);  

    while( i <glineCount )
        printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);

    return 0;

void open_vec_file(const char *filename, PIVPOINT *pivp)

    int i = 0;
    FILE *fp = fopen(filename, "r");
    char fileline[LINE_BUFFER];

    // open the file, first checking if it exists 
    if (fp == NULL){
        printf("ERROR: Could not open vector file %s\n", filename);
        while ( fgets( fileline, LINE_BUFFER, fp) != NULL)
            sscanf( fileline, "%f%f%f%f", &pivp[i].x, &pivp[i].y, &pivp[i].u, &pivp[i].v);
            printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);

[QUOTE=tdba.316;1399731]Hey :D this is my first post here^^, and it's a problem with an exercise from the book C++ Primer Plus, which I have been self-studying (I'm the beginner).

The following code is how I did the exercise, which is in the header comment. It was built in VC++ 2010, and I entered 100 for all the 12 months for all 3 years in the resulting program.
The result should have been 1200 for each individual year and 3600 for all the years, but the program reported -858992260 for each individual year and 1717990516 for the combined years O.O I can't figure out what the problem is, so I hope you guys will help me^^

Here is the code:

Do Programming Exercise 4, but use a two-dimensional array to store input for 3 years
of monthly sales. Report the total sales for each individual year and for the combined
Exercise 4:
You sell the book C++ for Fools. Write a program that has you enter a year’s worth of
monthly sales (in terms of number of books, not of money). The program should use a
loop to prompt you by month, using an array of char
(or an array of string objects, if
you prefer) initialized to the month strings and storing the input data in an array of int.
Then, the program should find the sum of the array contents and report the total sales
for the year.


int main()
{ ...