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

Congratulations Lardmeister for that achievement :) Well done!

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

Depending on the compiler you are using you need to install the redistributable files that are found in your compiler's install directory. For examp VC++ 2008 Express files on my computer are here: D:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT

Apparently you are using an earlier version of the compiler. Copy those files into the c:\windows\system32 directory or some other directory that's in the PATH environment virable folders. Make sure not to overwrite files by the same name that's already in that directory because it might cause problems with other programs.

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

In order to learn how to program you first need to learn how to read. Please read my previous very very carefully and you will find the answer to your problem.

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

>>except at the end the program is bombing out
Don't know -- probably something else in your program. Did you declare temp variable big enough to hold all the characters in that string ?

>>if (size == 1 )
Why that condition? Just delete the loop and do it like this, unless of course there is other code within that loop that you haven't posted.

strcpy(temp,pOutData[1]);
	//printf("Temp = %s\n", temp);
	ptoken = strtok(temp, ";" );
	while( ptoken != NULL )
	{
   	     printf ("Results 2nd:%s\n", pOutData[1] );	
  	     printf ("ptoken:%s\n", ptoken );	
	     ptoken = strtok(NULL, ";" );
	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Good luck with that tutorial :) Glad to have you here at DaniWeb. I took a COBOL class once in college -- hated it.

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

Linky

But it is a little difficult to learn -- I'd suggest you start with Dev-C++ until you get your feet wet. There are several other free compilers too.

If you are interested in books then read one of the Read Me threads at the top of this board. It contains a lot of suggestions.

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

I would copy the string into some local buffer because strtok() will replace the ; with null characters, which destroys the original string.

char temp[255];
strcpy(temp,*pOutData);
pToke = strtok(temp,",");
// rest of program here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

tutorial here

This is complicated programming and you need to have a good understanding of C or C++ programming. Not a task for beginners.

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

pOutData appears to be a pointer to a pointer or a 2d array of strings, like argv parameter to main() In either event line 5 can not work because strtok() only works with 1d character arrays. pOutData needs to be a pointer that is declared similar to the way you declared pToken

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

>>strcpy(input,line);
What's the initial value of i? Answer: undefined because you didn't set it to 0 before that loop started.

>> while (line!=EOF)
line will NEVER EVER be EOF. So that's the wrong way to code that loop. What you need to do is create another integer that counts the number of lines read so that in this loop you can check the number of lines. You have already done that to an extent -- in the loop that reads the data you are using variable i but then the program uses that same variable over again. Use a different counter. for(i = 0; i < counter; i++)

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

Can't speak for others but those kind of ads don't bother me at all and I'll occasionally click on one to see what its about. I don't have any clues about your other questions.

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

Do you mean you deleted c:\temp ? Very Very bad thing to do because many other programs use that too for storing temporary files. Re-create that folder and the compiler will be happy.

It you check the environment settings you will probably find one called TEMP=c:\temp. That's what programs look at to find out where the temp directory is located. If you delete that folder without making changes to the TEMP environment setting your computer will be in big big trouble.

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

for( i = 25; i >= 1; i--) Check that i is greater than 1. In your code 25 will always be greater than i because i starts out at 25 and goes down from there.

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

Start at the top of the list you posted and do them just one at a time. Don't attempt to do them all at once. Do the first requirement then compile, correct bugs, and compile again until all problems have been fixed. Only then do you begin the next statement.

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

Maybe you should use a different compiler -- there are several free ones, such as Dev-C++ and VC++ 2008 Express.

Here is a nice tutorial that lots of people use.

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

post questions in the language of your choice, such as C, C++, C#, VB, etc.

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

Hi Ancient Dragon,

. Can you guys tell me how can I make my contribution (donate some money) to this site???:)

Beast Regards,

gazoo

Scroll up to the very top of this page and you will see "DONATE" link on the very top line. You get other benefints for donating too, such as no ads.

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

stop using inlinecode and adding your own color tags. It makes it very difficult to copy/paste into my own compiler. Use standard code tags and your program will be color coded.

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

First I would create a structure (or class if you like) to contain all the information for one company. Change the function to accept a reference to a vector of structures instead of all those string arrays. That will simplify your intire program.

struct company
{
    string companyName;
    string something; // e.g. A123, whatever that represents
    string somethingElse // e.g. case
    // etc. etc for each of the other fields
};

// create an array to hold the structures
long readFile (vector<company>& colist)
{
    // now read the data
    struct company co;
    while( getline(fin,co.company) )
    {
       getline(fin,co.something);
       getline(fin,co.somethingElse);
       // etc for each field
       //
       // finally put co into the vector
       colist.push_back(co);
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete lines 9 and 10 because that doesn't work, and replace it with just this one line typedef Contribution BigSpender[MAX];

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

>>But know how I can access to my values in array
Is that the question -- how to extract each of the numbers in the string ? extract them using sscanf(). There is a simple example

int main()
{
    char line[] = "123 234.56 789";
    int a, b;
    float c;
    sscanf(line,"%d %f %d", &a, &c, &b);
    printf("%d %f %d", a, c, b);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>This is the first question I have, does that mean studentType is the base class or persoType is the base class?
personType is the base class.

>>cout << studentList[count].getFirstName
getFirstName is a function, so you need parentheses just like calling any other function cout << studentList[count].getFirstName() Same with getLastName -- use parentheses as above.

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

There are two versions of getline() -- cin.getline() is for character arrays and getline(cin,...) if for std::strings.

You didn't say how the data file is formatted, so I just assumed it has all the information on one line because you said you wanted to use getline(). Post a few lines of the data file so that we can see how it should be read.

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

Yes because they will contain no windows-specific function calls. You should be able to port it to *nix version of QT without any code changes, assuming you did not make any os-specific function calls outside what QT gives you.

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

Here is how to code that loop. You can delete lines 8, 10 and 19

int count = 0;

while( getline(fin, product[count]) )
    count++;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> I wonder what's next.
According to legend Pope Benedict XVI is the last pope. The next one will be Saten himself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
struct Contribution
{
	string name;
	double amount;
};

const int MAX = 25;

typedef Contribution BigSpender[MAX];

const string NAME_FILE = "names.txt";
const string CONTRIBUTION_FILE = "slush.txt";

void InitProgram( BigSpender& ContributionRec );

int main()
{
    BigSpender ContributionRec;
	InitProgram( ContributionRec );
	return 0;
}

void InitProgram( BigSpender& ContributionRec )
{
	return;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Again, sorry it doesn't have any color, but I haven't had a chance to learn how to use that yet

Read your PMs. You have a PM that shows you how to do that. Scroll up to the very top of the page and click the PRIVATE MESSAGES link.

And re-read the code in my original post here. What you implemented is totally wrong. Paying attention to detail is required in programming.

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

You need to look for socket programming. Exactly how to do it depends on what operating system you are using. www.DataReel.com has a large free library that contains client/server programs among other things and is ported to both *nix and MS-Windows.

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

>>yes i did.
Than I guess you just ignored it because you didn't change a thing about those loops. I'm not going to try to answer your questions if you just ignore everyone's suggestions.

Repost without all those color tags and use code tags to make it readable.

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

Post what you have done so far to resolve this. What compiler and operating system are you using, because it will make a difference how you create the threads.

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

Its impossible to read that code because of all the color tags you inserted. Did you bother to read my previous post ??? (I'll bet you didn't)

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

I like Bud, but only after it has aged for at least 6 months. I buy a case and leave it sitting for 6 months to a year before drinking it.

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

Assuming we're all still here of course.

I don't know about you but I will be :)

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

ancient said but according to that page, he does.

That was posted before Dani and Happygeek gave me modly powers here :)

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

The use of num1 and num2 in lines 17 and 22 is destroying the values you entered on line 13 and 15. Use some other variables on lines 17 and 22

for (int num3 = 1; num1 <= num1; num3++)
{
       for (int num4 = 1; num4 <= num2; num4++)
       {
           cout << num3/num4 << '\t';
       }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Even hear of google ? If not, then you should learn to use it.

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

>>Is it possible to print anything on screen in C or C++ without using main().

Yes -- write a MS-Windows win32 api program which uses WinMain() instead of main(). Or use VC++ 2008 and it will generate a console program that starts with _tmain().

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

Read this

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

If you enter 2-28-2008 why do you want to display 2-29-2008 ? All you need to do is validate whether February has 28 or 29 days. If you enter 2-29-2007 then your program should display something to the effect that you entered the wrong number of days.

if( leapyear(year) && month == 2) 
{
    if( dd > months[1]+1 )
       cout << "Invalid # days\n";
}
else
{
    if( dd > months[1] )
       cout << "Invalid # days\n";
}

There is a shorter way to express the above

if( mm == 2)
{
    // if february
    int ndays = (leapyear(year) == true) ? 29 : 28;
    if( dd > ndays)
        cout << "Error\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>..that which line in above code is assigning the values of Disk-file to the arra
line 7 infile >> sort[count] >>and secondly above code is just showing the String..its not sorting data..
All you asked was how to read the data from disk instead of from the keyboard, so that's all he posted. you already posted the sorting code on your original post. Just do what you did before.

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

>>Don't you think it's unfair to dismiss Knuth's counter-argument due to age yet allow the even older article to stand as a valid argument

Yes -- Dijkstra's article isn't relevent any more either :)

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

No one here is going to do your homework for you. Sounds like you are way over your head, so either drop the course or hit the books.

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

please answer for this..i iwll be very grateful to u

You didn't ask a question. All you did was dump your homework assignment here.

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

Sorry what is that mean??

Re-read the code you posted -- its there twice. Repost and this time preview your post before hitting the Submit button.

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

post code. If its reading character by character then it will pick up spaces too.

char c;
while( infile.get(c) )
{

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

I added some more to my previous post -- please re-read it for more suggestions

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

The code you posted isn't very useful. Check for missing semicolons, especially at the end of the class declaration

class object
{
<snip>
};

Looks like the problem may be in the way you have the header files included.

food.h >> objects.h >> maincontrol.h >> food.h

So nothing is fully defined. Try adding class forward references.

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

There are many companies who have that rule as a coding standard. One way in and only one way out of a function.

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

you double posted the code.