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

Is using '#' to deliniate lines required by the assignment or is it something you dreamed up on your own?

while( cin >> name >> street >> city >> state >> zip)
{

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

>>That code is probably riddled with bugs
Yes it is.

>>and I'm still half a sleep
you should have went to sleep instead of posting that code. Attempting to program while half asleep is not good -- been there and done that (unsuccessfully I might add).

const int ARRAYSIZE = 100;
string buffer;
string lines[ARRAYSIZE];
int linecount = 0;
ifstream inFile(file);
if( !inFile.is_open()) // did open succeed
    return;
while( linecount < ARRAYSIZE && getline(inFile, buffer) )
{
    lines[linecount] = buffer;
    ++linecount;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Commenting code is very good -- but commenting with wrong information is very very bad.

>> // Clears the unused characters from the buffer
that function does not do what you said it does. The clear method clears error bits.

>> Ignores the buffer generated by cin.clear
Doesn't do that either. cin.clear() doesn't create a buffer

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

line 10: you don't do math such as multiplication in the section that declares variables. You probably want to do this:

int Capacity;
int * items;
int count ;

lines 16-21 don't make sense, and the function has no closing brace.

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

Glad to see you are posting this question everywhere you can :)

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

>>I no longer have computer access at work
What! you are supposed to be working. Come back soon :)

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

Tom & Jerry, Heckle & Jeckle, Popeye (I live about 40 miles from his home in Southern Illiinois), Mighty Mouse, Deputy Dog just to name a few. Also enjoyed many of the cartoons when my children were kids.

I still enjoy watching those old cargoons, especially Scooby Doo. Don't like the new crop of cartoons because Hollywood has make them too PC and taken all the violence (and fun) out of them.

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

elf (not my favorite, but i couldn't think of something else)

maybe the santa clause movie (1st one)

Yes, I like Tim Allen too -- very funny commedian, and he makes a good Santa.

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

We have to be very careful not to get bitten where I live because mosquitoes may carry west nile virus. So we try to avoid being outdoors for long periods of time especially at night. There are normally a few deaths in my area each year from those insects. I don't know what affect they have on bats, who love to eat them.

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

do what I did -- use it as a door stop.

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

Miracle on 34th Street (the original version, not the updated piece of trash).

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

First I would completly write a new file with the information from the original. Read the original file 26 times (once for each column). The first time through read only the first column of each 300,000 rows and write them out to the new file as the first row. Rewind the file back to the beginning them read again but this time only read the second column. Write those out to the new file as the second row. Repeat the process for each of the 26 rows in the original file. Note that it is only necessary to open the original file ONCE, not 26 times.

If your computer has enough RAM you might be able to do this by reading the original file all into memory at one time, reformat it in memory and write it out to the output file. This would be the fastest way, but also the most memory intensive.

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

read your text book. while is just one of several types of loops. See this tutorial

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

>>Would anybody know a way to repeat a program
use a loop

while( not done )
{
    // display menu
    // get input
    // if 'Q' entered then exit the loop
    // do something
}

Not sure what you are trying to do that that code you posted. But rate = rate; doesn't do anything, so you might as well just replace it with a simple semicolon.

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

isn't that 2,000 just the tax? VAT = tax?

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

>>and any other pointers with how I should code the else porition on my operator +
The easiest way is to use the mktime function in time.h. Populate a struct tm structure with the year, month, and day + days_to_increment, then call mktime() to normalize the data. Upon return the tm structure will be corrected.

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

after line 86 you need to actually read a line from the file -- you can't just simply ignore it.

string line;
for(i = 0; i < 6; ++i)
{
    getline(infile,line);
    if( i > 1)
    {
          // convert to number, you can use stringstream class to do that.
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The provisional license costs £45 ($90 ish) then when you pass it is upgraded to a full license free of charge.

I think its about $20 USD here and kids can get a license at age 16. But its restricted -- must have an adult in the front seat unless driving to/from school.

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

Hope this helps.

>>repetition

int main()
{
    while(true)  // start of loop
    {
          // repeat code goes here

    } // end of loop
}

>>no user defined functions
Just a function you write yourself. Call it anything you wish except main

int userDefinedFunction()
{
   cout << "This is a user defined function\n";
   return 0;
}

>>and no option to quit

int main()
{
   char option;
    while(true)  // start of loop
    {
          cout << "Press 'Q' to quit\n";
          cin >> option;
          if( option == 'Q')
                break;
          // repeat code goes here

    } // end of loop
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>CHARACTER ST1*10
probably char st1[10]; >>CHARACTER ST*(*)
My guess is char *st;

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

line 13 -- you forgot the semicolon at the end.

line 15: need to escape the '\' character djout.open("C:\\TEST.txt"); I'm not going to tell you the rest of the errors. Just fix them one at a time and compile after each correction.

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

use a linked list of structures. Read a value from the file, search the list to see if its already in the list. If found just increment the count. Otherwise if not found then add a new node and initialize the count to 1. Note: for value in the below structure multiply the float read from the file by 100 to get an integer. Don't use floats in the structure because comparisons may be inexact.

struct data
{
     int value;
     int count;
};

>>and also how to read the data in better way because the header is character.
better than what? you didn't post any code.

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

what do you think the answer is? If you have 30 apples and I give you 20 more then how many apples will you have? The answer is that simple.

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

nope -- try again ?

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

I've done that too. :)

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

you should have used cout not cin. Or if your intent is to get keyboard input then use the >> operator, not <<.

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

yes, but in the original array which element is set to 9?

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

see the answer here

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

>>then in addition, what does
Think about it and post your answer (or guess)

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

If you want findMax() to change the value of ptr in main() then you have to pass the parameter by reference and not by value.

void findMax(int arr[], int n, int** pToMax)
 {
    ...
    *pToMax = &arr[0];

}

int main()
{
...
    findMax(nums, 4, &ptr);
}

Or since this is c++

void findMax(int arr[], int n, int*& pToMax)
 {
    ...
    pToMax = &arr[0];

}

int main()
{
...
    findMax(nums, 4, ptr);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which line was the error on ?

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

The first line initializes the values of the array.
The second line is a syntax error. It should be int* ptr = &array[0]; The last line sets the value of te first array element to -1.

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

how about a linked list ?

or something like this:

void foo(int x)
{
   int n = 0;
   cout << "Enter a number " << x << ":\n";
   cin >> n;
   if(x < maxNum) // maxNum declared elsewhere
        foo(x+1);
   cout << "n = " << n << "\n");
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't be sorry -- clean it up first and fixing it will be a lot simpler. If you are concerned about time then you have already wasted too much time trying to figure out that crappy code. Here are some suggestions.

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

>>I open the data file 26 times
Why ??? Your program is failing to close the file before opening it again.

>>I need to traspose the data
What do you mean by that? to make columns rows and rows columns ?

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

on MS-Windows fopen() returns NULL on error, which it should do on all other operating systems.

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

If you are taking an assembly class why are you wrinting C program? How write to the screen that depends on the operating system you are using because each one is different. For MS-DOS, start here

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

This is one way to do it.

int main ()
{
   float f = 123.457678F;

   int a = (int)f;
   float b = f - (int)f;
   if(b > 0.5F)
       a++;
   cout << a;
   return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your code formatting is absolutely horrible! Completly unreadable. And that is probably why you don't understand the error. Reformat it, indent it properly, and you will probably see the problem. And don't be afraid to put { and } on their own separatelins, unlike the horrible code in line 122.

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

>>what are code tags i dont understand why i got an infraction
Look very closely in that edit box -- there are grey words there that explain code tags. Also read the rules because they are explained there too. Finally read the Announcements at the top of the c++ board because this is the third place where they are explained. You got two infractions so far because you have failed to read any of the above mentioned threads.

>>what do you mean by check the amount in the loop
It means to verify that the loops do not exceed the number of entries you made. loadScores() (should) change the value of amount to be the number of integers you enter at the keyboard. Just use that value in other places, something like below which was extracted from function displayArray()

while( x[i] >= compe[j] && i < size && j < size)
   {
      cout<< x[i] << "  ";
      i++;
      Gfrequency[j]++;
   }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What? there is nothing to correct because the function even already returns true or false, unless you just want to rewrite it like this:

bool even(int x1)

{

return (x1%2 == 0) ? true : false;

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

>>im using I/O with this data set
doesn't matter -- the program should work the same with any data set.

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

Of course nothing happens because there you did not post any executable code. All you have is a structure and a function prototype.

also try reading some of these google links

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

And if you initialize array x on line 17 to 0 you will not get all those crazy numbers. int x[100] = {0};

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

This is the output I get. It is obvious you are failing to check for maximum quantity of numbers entered at the keyboard.

10
20
50
60
^Z
Grade Distribution
==================
A:
B:
C:
60 50 20 10 D:
-858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -8589934
60 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858
993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460
-858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -8589934
60 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858
993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460
-858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -8589934
60 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858
993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460
-858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -8589934
60 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858
993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460
-858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -8589934
60 -858993460 -858993460 -858993460 -858993460 -858993460 -858993460 -858
993460 -858993460 -858993460 -858993460 1245080 4272406 1 9256408 924983
2 -633697869 0 0 2147336192 3579545 0 0 1245184 0 1245020 142 124514
8 4264096 -630588893 0 1245088 4271965 1245100 1980315699 2147336192 12
45164 2002954685 2147336192 1232591 0 0 2147336192 0 0 0 1245112 0 -
1 2002750450 2003025963 0 0 0 4264346 2147336192 0 2020893505 32 1 1
2296 220 0 32 0 20 1 7 52 364 1 0 0 0 0 0 2 438759246 644 68
716 608 0 760826203 1324 50 1376 768 0 -214797894 2144 74 2220 798
0 852421325 3020 66 3088 822 0 944791496 3912 94 4008 872 0 F:
==================
Grade Frequency
===============
A: 0
B: 0
C: 4
D: 193
F: 0
===============
n = 5
Class Average: -1.71799e+008
Class STD: 3.43597e+008
Press any key to continue . . .

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

It isn't working because you changed that function wrong. It was correct the first time. After that you need to add checks that loops don't check beyone the value of amount because that is how many valid items are in the array.

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

The infinite loop is the one that starts on line 68 because the i is never incremented.

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

you need to move lines 14 and 15 inside the do loop.

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

>>the program gives me an infinite loop
where ? If you don't know where then add some print statements or use your compiler's debugger.

And your bubble sort algorithm is wrong because it goes through too may iterations and comparisons.

void sortScores( int x[], int size )
{
   for( int i = 0; i < size - 1; i++ )
   {
      for ( int j = i+1; j < size; j++ )
      {
         int temp;
         if ( x[ i ] < x[ j ] )
         {
            temp = x[ i ];
            x[ i ] = x[ j ];
            x[ j ] = temp;
         }
      }
   }
}