Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

convert all the calculations to floats and it will work. as integer, 1 * 0.2 = 0 because decimals are discarded.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See this thread how to avoid system("PAUSE");

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Copy/paste what you see on your monitor when you run the program.
here is what I get when I enter 5 students. What is wrong with it?

PROGRESS REPORT

        Rollno          Total           Grade

         100            400             B

         200            374             C

         400            350             C

         300            325             C

         500            250             D
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

we can ignore the part that start with the $ because all the important information is before that, so the answer would be that the data is separate by a blanck space.

The the code I posted will probably work because getline() will read the entire line, then use stringstream to separate it into individual parts, tossing out the part that starts with the $ symbol. You could do it as CoolGamer suggest too, but it may not be as immediately apprarent what is going on when you read the code in a month or two.

and about the code the data should be read it a save the data that's been read in a document or save it in a list all the data that is been read it. Not to put an object in a list.

Jason

I don't understand what you are trying to tell us. After reading each line either save the data into another file (why???) or add it to a list -- which is what I did in my previous post. In order to put the data into an array you have to add the data to a class or structure, then put an instance of that into the array. It doesn't matter whether its a Cgps class or something else you design. I used Cgps because that's the code you posted. That's the most reasonable way to keep all that data organized within your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please post questions about MS SQL here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please post the error message(s) and line number(s).

WARNING-you may lose significant digits..

Is that it? And on line 97?

If yes, the warning is telling you that temp is an integer and Grades is a character. You can remove the warning by typecasting Grade[j] = (char)temp;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is one Exactly how to write the scripts (programs) depends on what programming language you want to use. C, C++, Python, PHP, C#, VB, etc. etc. ????

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will have to post the code. The file probably isn't in the directory where you think it is, so you might have to provide the full path to the file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

.i need to know how to rank the students after sorting them in decreasing order of their total...any suggestions..plz reply..

what do you mean by "rank them" ? assign a number like the first one in the list is 1, the second one is 2, and the third (last) one is 3? That should be easy to do, just use the loop counter as shown in RED below.

for(int i=0;i<n;i++)
{
cout<<"\n\n\t "<<rollno[i]<<" \t\t"<<Total[i]<<" \t\t"<<Grade[i] << "  Rank: " << i+1;
 if (Grade[i]=='E')
  {cout<<"\t FAIL" ;}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ok thatassignment A to everyone was a mistake...but still when i run it..n enter 3 values i can c only 2 ..y is that happening?

I ran the code you posted last and I entered 3 students that that's exactly what it displayed at the end.

What compiler are you using? I used vc++ 2008 Express, replaced iostream.h with iostream (no .h extension) and added using namespace std; But those changes should not have caused the problem you describe.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
1213891110.84 0 41.3831338 2.1161887 66.2 7 1.2 -294.85 -554.07 -56.49 -336.30 -559.84 41.46 5.77 $GPGGA,155830.00,4122.98803,N,00206.97132,E,1,07,1.2,66.21,M,51.31,M,0.0,,*50

That file format seems to be inconsistent -- are the fields separated by spaces or by commas? Or is that last part beginning with $ all one field?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a little more specific info. I have no idea how to convert that double timestamp in the file to the individual time parts that's in the Cgps class. How was that double number created ? You will probably have to get decode information from whatever program created it.

// read the file
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
...
...
...
// an array of Cgps classes
vector<Cgps> list; 

ifstream in("filename.txt");
std::string input;
float timestamp,latitude, longitude, altitude;
while( getline(in, input) )
{
    // split it into individual parts
    stringstream str(line);
    str >> timestamp >> latitude >> longitude >> altitude; // etc. etc for each variable
    // create class and initialize with above data
   Cgps gps;
   gps.latitude = latitude;
   // etc etc for each field that was read.
   ...
   // now add to the array
   list.push_back(gps);    
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 71-79: You assign an 'A' to everybody.

I ran the program and got this

PROGRESS REPORT





        Rollno          Total           Grade

         100            380             A

         300            200             E        FAIL

         200            150             E        FAIL
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you forgot do { for Math Marks on line 54

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is something like how to code the program to read each line of the file.

#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
...
...
ifstream in("filename.txt");
std::string input;
float timestamp,latitude, longitude, altitude;
while( getline(in, input) )
{
    // split it into individual parts
    stringstream str(line);
    str >> timestamp >> latitude >> longitude >> altitude; // etc. etc for each variable
    // create class and initialize with above data
    <snip>
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The loops on line 58 and 59 are still wrong. Use the < operator, not the <= operator when counting from 0.

for(int i=0;i<(n-1);i++)     
{  for(int j=(i+1);j<n;j++)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You could do something like this:

do
{
    cout<<"Enter English marks  ";
    cin>>english[i];
    if( english[i] > 100)
       cout << "Error\n";
} while( english[i] > 100 );

And if you are going to do that several times just write a function that returns the value

int GetEntry(string prompt)
{
    int value = 0;
    do
    {
          cout << prompt << "\n";
          cin >> value;
          if( value > 100)
              cout << "Error\n";
     } while( value > 100);
    return value;
}

int main()
{
    ...
    English[i] = GetEntry("Enter English Marks");

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Myself, I would have used a structure for that information so that you can easily sort structures instead of so many simple arrays.

struct student
{
    int total;
    // rest of student info goes here
};

But if you want to leave it the way you have it, then during the swap you have to swap all the arrays, not just the Total array.

for(int i=0; i < (n-1); i++)
{
    for(int j = (i+1); j < n; j++)
    {
       if (Total[j]>Total[i])
       { 
           temp=Total[i];
           Total[i]=Total[j];
           Total[j]=temp;
           temp = Grade[i];
           Grade[i] = Grade[j];
           Grade[j] = temp;
           // etc etc for each of the arrays.
        }//if statement
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here's how to do it in c++, which does not use fopen() or anything else from C's stdio.h

#include <string>
#include <fstream>
using namespace std;

int main()
{
    string filename;
    char path[_MAX_PATH];
    string iexename = "Services.exe";
    GetCurrentDirectory(_MAX_PATH, path);
    filename = path;
    filename += "\\";
    filename +=  iexename;
    // open the file
    ifstream in( filename.c_str(), ios::binary);



}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As a beginning you should start at the beginning of your learning, not jump smack dabb into the middle of the lake. Buy a book on introduction to c++ and start studying from page 1, not page 500. The Read Me threads at the top of this board have lots of information about that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) Array elements start counting from 0, not 1. That means the first element of Total is Total[0] and loop counters should count from 0 to but not including the number of elements in the array.

Example: The loop counters beginning on line 58 should be (and that's how I write simple bubble sort algorithm too :) )

for(int i=0; i < (n-1); i++)
{
    for(int j = (i+1); j < n; j++)
    {
         // blabla
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't double post the problem in multiple threads because it only causes confusion. I'm closing this thread so that the discussion can continue in the other thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>when i save data in different files and ask them to fetch the same data from files but it just show me the data of last file no matters if i enter the name of first file

You have to add some more code to read the file after it is opened on line 62. Your program opens the file then just ignores it.

>>and it is adding average of last student with the current one
You have to reinitialize total to 0 before starting the loop on line 25.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

About the files: I see now that your program creates them. Its not necessary to have an array of file pointers, e.g. FILE *p[2]; . All you need is one and just reuse it. FILE* p; You are asking people to enter the birth date as a single integer -- I don't know about you but I like to enter my birthdate in MM/DD/YYYY or MM-DD-YYYY format and you can't do that with your program. Suggest you change the data type of birthdate to a character array so that you can enter it in normal fashion.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The indentation of your program is terrible -- hopefully it was just a problem with posting here. So here is a corrected copy

#include<stdio.h>
#include<string.h>
#pragma warning(disable: 4996)

float avg(float);
main()
{
    FILE *p[2];
    int k,students=10,subjects=4,i,j,id_number,date_of_birth,fail=0;
    float marks[100],total=0,avg;
    char name[30],course_enrolled[30],filename[10];
    for(i=1;i<=2;i++)
    {
        printf("filename"); 
        scanf("%s",&filename);
        p[i]=fopen(filename,"w");
        printf("Enter Name of Student\n",p[i]);
        fscanf(stdin,"%s",&name,p[i]);
        printf("Enter Course In Which Student Is Enrolled\n",p[i]); 
        fscanf(stdin,"%s",&course_enrolled,p[i]);
        printf("Enter ID Number Of %s Enrolled in Course %s\n",name,course_enrolled,p[i]);
        fscanf(stdin,"%d",&id_number,p[i]);
        printf("Enter Date Of Birth Of %s Enrolled in Course %s and\n ID-Number is %d\n",name,course_enrolled,id_number,p[i]);
        fscanf(stdin,"%d",&date_of_birth,p[i]);
        for(j=1;j<=4;j++)
        {
            printf("Enter Marks for Subject %d for Student %s\n",j,name);
            fscanf(stdin,"%f",&marks[j]);
            total=total+marks[j];
            if(marks[j]<50)
                fail=fail+1;
            else
                continue;
        } 
        avg=(total/400)*100;
        printf("AVERAGE=%f\n",avg);
        if(avg>=70)
            printf("Grade A\n");
        if(avg>=60&avg<70)
            printf("Grade B\n");
        else if(avg>=50&avg<60)
            printf("Grade C\n");
        else if(avg>=45&avg<50) 
            printf("Grade D\n");
        else if(avg>=40&avg<45)
            printf("Grade E\n");
        else if(avg<40)
            printf("Fail\n");
        if(fail>=2)
            printf("Student is failed and cann;t promote\n");
        else
            continue;
        fclose (p[i]); 
    }
    for(k=1;k<=2;k++)
    {
        printf("Input filename"); 
        scanf("%s",&filename);
        p[k]=fopen(filename,"r");
        fprintf(stdout,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %d\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,avg);
        fclose (p[k]);
    }
    getch();
}

When I compiled it using VC++ 2008 Express I got several warnings which you need to correct. NEVER EVER ignore warnings because most of the time they are really errors.

>>test1.c(39) : warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence

That warning message tells you to look at line 39 and check of the & operator is correct. Its not what you want -- you wanted the boolean && operator, not the bitwise & operator. The code has similar problem on other …

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't have my crystle ball with me at the moment, so please describe the problem with your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are a few tutorials, such as this one (click here)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The link doesn't work and you didn't describe the problem with your code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are hundreds of tutorials. A few here on DaniWeb, others you can find with google. Avoid any tutorial that uses iostream.h -- the one without the *.h extension is the current one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe the question is simple but the answer is pretty complex. First you need to learn how to write Windws programs and understand the windows messaging system. Here is a tutorial to get you started with that. It only touches on the highlights, and there are months (or years) of studies to understand all of it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

declare them at the top of world.cpp. You have to treat static class variable just like any other normal global variable.

#include <vector>
using std::vector;

#include "Breeture.h"
#include "World.h"


//initialize class static variables
unsigned int world::worldPopulation = 0;
unsigned int world::totalBreetures = 0;


World::World(vector<Breeture*> *initialBreetures) {
    livingBreetures = *initialBreetures;
    worldPopulation = livingBreetures.size();
    return;
}
<snipped>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think so because the registry isn't a file. If you know the filenames of the registry (there are more than one file) you would get the timestamp the last time the registry was changed, that won't tell you anything about an individual registry key.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How about?

system("start www.google.com");
system("start http://www.google.com");

That worked on Vista.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might begin by reading DaniWeb's Mission Statement. Then navigate through each of the forums, reading the introductions at the top of each forum page. They will tell you what each of the forums are about. Also don't forget to become familiar with DaniWeb FAQ and Community Rules

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On Windows you can just put the website on the command line and it will open in the default browser, i.e. system("http://www.google.com");

doesn't work on Vista

D:\Users\AncientDragon>www.daniweb.com
'www.daniweb.com' is not recognized as an internal or external command,
operable program or batch file.

D:\Users\AncientDragon>

Also tried other variations

Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

D:\Users\AncientDragon>www.daniweb.com
'www.daniweb.com' is not recognized as an internal or external command,
operable program or batch file.

D:\Users\AncientDragon>http://www.daniweb.com
'http:' is not recognized as an internal or external command,
operable program or batch file.

D:\Users\AncientDragon>"http://www.daniweb.com"
The filename, directory name, or volume label syntax is incorrect.

D:\Users\AncientDragon>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
return( strcmp(tag, buff, l) ) ; /* why he uses 3 parameters? I think it should be 2 parameters in "strcmp" ? */

That line is definately incorrect -- strcmp() only takes two parameters, not thread. Maybe it should have been strncmp() which has 3 parameters ?


mystrcmp() is missing the closing function brace -- }


line 20: where is buff declared?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First get it to work with a command-line parameters then you can try to make it a GUI if you wish. Probably step 1 would be to just hard-code the information in the program so that you don't have to type it every time you run the program (which might be several hundred times).

If you search DaniWeb for calculators you will find several relevent threads (click here).

Unless its a requirement of your program, you probably shouldn't try to do GUI because its way beyond your current programming abilities.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That ball looks like something similar I've seen on American Gladiator TV show. Looks like a lot of fun -- for someone half my age :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Once you know the web site, just spawn a process similar to below. Create a string like that, replacing DaniWeb.com with the site you want to go to. Note: this is on my Vista box so your browser might be in a different location on your computer. Right-clikc on your browser's shortcut then select properties. That will tell you the full path to your browser.

system("\"D:\Program Files\Internet Explorer\iexplore.exe\"  www.DaniWeb.com");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>strcpy(OB.v2, v1); //OB is an object of Class B

You have that backwards -- first parameter is destination and second parameter is source.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have to implement the code for DOS...

You are probably in really big trouble then if the os is MS-DOS 6.X or earlier. you will need to find (free or buy) a TSR that reads/writes to/from serial port. You might try some of these google links.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This looked like fun, so here's a start. I wouldn't turn this in because your teacher will know it isn't your work.

#include <iostream>
#include <string>
#include <algorithm>
using std::cin;
using std::cout;
using std::string;

// macro to calculate the number of elements in 
// an array.
#define SZARRAY(x) (sizeof(x)/sizeof(x[0]))

class wagon
{
public:
    typedef enum {unknown, red, green, blue} COLOR;
    wagon() 
    {
        m_color = unknown;
        next = prev = NULL;
    }
    wagon(COLOR color) 
    {
        m_color = color;
        next = prev = NULL;       
    }
    COLOR getColor() {return m_color;}
    wagon* next;
    wagon* prev;
private:
    COLOR m_color;
};

// menu stuff
//
// declare array item numbers
typedef enum {
    UNK,IR,IB,IG,RR,RB,RG,MRB,MRG,MBR,MBG,MGR,MGB,DW,NR,NB,NG,P,Q
} MENUITEMS;

// structure to hold menu information
struct menuitem
{
    string key;  // this is what you type
    string text; // explaination for key
    MENUITEMS item; // item number
};

// an array of menu items and associated numbers.
menuitem items[] = {
    {"IR ","Insert a red wagon from the head.\n", IR},
    {"IB ","Insert a blue wagon from the head.\n",IB},
    {"IG ","Insert a green wagon from the head.\n",IG},
    {"RR ","Remove all red wagons from the train.\n",RR},
    {"RB ","Remove all blue wagons from the train.\n",RB},
    {"RG ","Remove all green wagons from the train.\n",RG},
    {"MRB","Get the first red wagon and move it to the next of the first blue wagon.\n",MRB },
    {"MRG","Get the first red wagon and move it to the next of the first green wagon.\n", MRG},
    {"MBR","Get the first blue wagon and move it to the next of the first …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do your own homework

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Does any one have any recommendations as it certainly works for the limited durations I was aloud. Are there any particular forums which would allow me which have a big active membership. Preferable a Uk based forum

Thanks

Recommentations: DaniWeb is one that fits your description.

I looked at your site (the link in your signature). Maybe you should post in Website Reviews Form to get some great ideas how to improve your forum.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on what you consider "reasonable rates". Bill Gates might considere $1 Million/year reasonable, but since I doube you are a multi-billionaire that problably isn't quite in your price category. Why don't you just google for cell phones to see what you can come up with.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb -- glad to see someone else in my age group here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sounds like you want to write a screen saver? Maybe these google links will help

How to make the words display with a lazer depends on the lazer. There are many kinds of lazers -- I once write a program for a large lazer that etched words onto plastic items in a factory.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What operating system? MS-Windows see Communications Reference guide.