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

read the assignment again, and re-read it again and again until you understand it. IsLeapYear() is supposed to return TRUE if the year is a leap year or FALSE is the year is not a leap year. The function LeapYear() that you posted seems to do that. The functon IsLeapYear() that you posted does not do that, actually I have no clue what its purposes is. Delete IsLeapYear() and rename LeapYear() function to IsLeapYear().

In function main() you have to enter two years -- your program only gets one year. Then also in main() you need to create a loop that calls IsLeapYear() for each year between the first and second years that you enter from the keyboard.

Don't forget -- years prior to 1582 AD do not have leap years because the Gregorian calendar wasn't created until February 24, 1582.

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

>>any ideas how to fix it?
fix what? you didn't say what's wrong with the code you posted.

why does isLeapYear() take a double as parameter? It should be an integer; afterall years do not contain fractions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
scanf("%c",&words[i]);}
    atoi(&words[i]);}

above is useless. just input the text as normal characters. You don't have to do any conversion at all to get the ascii value of the characters -- data type char already contains the ascii value. To see if its odd or even

// get string from keyboard
fgets(words,sizeof(words),stdin);
//
for(int i = 0; words[i]; i++)
{
   if( (words[i] % 2) == 0)
   {
       // even ascii code
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just use fgets() to get the team name from the keyboard. You are experienced enough to have written all that complex code so surely you should be able to easily figure out how to use a simple function like fgets().

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

MFC has a class that's almost like Notepad. All you need to do is use either VC++ 6.0 compiler or VC++ 2005. About all you have to actually code is the menu items.

Don't know a thing about your dictionary question.

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

moved

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

Finally got it to compile by removing the code you have after the class declarations and reformatting to make it easier to read. Don't be afraid of using spaces in your program -- crunching everything up like you have it makes debugging difficult if not sometimes impossible.

#include <string>
using namespace std;

class Beverage;

class Bev_Iterator
{
protected:
	const Beverage *bev;
	const Beverage *next;
public:
	Bev_Iterator(const Beverage *bev)
	{
		this->bev=bev;
		this->next = 0;
	}
};

class Beverage
{
protected:
	Beverage *beverage;
	string desc;
public: 
	friend class Bev_Iterator;
	Beverage()
	{
		beverage = 0;
		desc = "unknown beverage";
	}
	virtual string getdesc()
	{
		return desc;
	}
	virtual double cost()
	{
		return 0;
	}
	Bev_Iterator* Iterator() 
	{
		return new Bev_Iterator(this); //error here
	}
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could use std::string class and just concantinate the value with the string

std::string query = "SELECT * FROM table1 WHERE id = ";
query += value;

now the problem is that if value is a string you will probably have to enclose it in quotes

std::string query = "SELECT * FROM table1 WHERE id = '";
query += value;
query += "'";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete line 3 -- that file (iostream.h) is for C++ programs, not C programs.

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

it isn't necessary to call srand() more than once during the lifetime of a program. The only way to generate an array of unique random numbers is to generate a random number then search the array to see if it has already been generated. If it has, then generate another random number and search again (as in your example program). calling srand() frequently will not help with this.

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

From what I remember from my ancient times is you need to #define UNICODE 1 (but that seems to have already been done !)

Yup -- like me, you too are outdated and nearly obsolete. :)

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

I would assume 8088 since its a little newer than 8086.

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

post the code you are writing. Are you allowed to use the math coprocessor for log and other math functions ?

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

first you need to post the code you have already written. The answer to your question depends on what kind of strings you are using -- std::string class or character arrays ?

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

First you need to learn how to properly format your program -- that is one of the sloppiest format methods I've seen in a long time. Here is an example Notice that you should use spaces very plentifully to make your program easier to read. Curly braces go on a line all by themselves to make them easy to find and match up.

And ust int main() -- never ever void main().

int main()
{ 
    for(int i=0; i <= 100; i++)
    {
        int a[10];
        for (int j=0;j<=10;j++)
       { 
           a[j] = rand() % 10;
          cout << a[j];
       }
    }
    return 0;
}

Now for your question: after generating a random number you need to search the array to see if it already exists. If it does, then generate another random number. You will probably want to put that into another function because you have to use it for several arrays.

int generate(int maxvalue, int array[], int arraySize)
{
   // put your code here which loop that generates
   // a random number and search the array 
   // for existance.  

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

You didn't say which version of VC++ compiler you are using. VC++ 6.0 and VC++ 2005 set UNICODE differently.

VC++ 2005: select menu Project --> Properties . Expand the Configuration Properties folder then select General category. Now on the right side see "Character Set" and change it to "Not Set".

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

sorry, but I am affraid this damn code is from link you just gave me...

Is there any good book?

The code in that link is perfect -- billions of people (:eek: ) have used it.

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

>>The struct date is the same one available in dos.h
that file is not supported by most compilers so we don't have any clue what the structure looks like. But I assume the day, month, and year are integers.

>>Isnt the writing of classes,having character arrays and a structure,to files allowed??
Yes, of course it is. But you have to be carefule that they do not contain pointers. You might also have to consider the packing factor set by your compiler. Packing is usually not a problem until binary files are read by programs created with different compilers.

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

what does struct date look like?

>>fout.write((char *)(&m),sizeof(m));
you really should not write c++ classes to the file like that. classes which contains other c++ classes such as std::string, std::vector, c-pointers, etc, can not be written like that. It is safer and more portable from one run of the application program to another to write out the individual members of the class individually.

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

>>But it looks like its not portable
Of course not -- its only for MS-Windows :)

Tutorial here

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

people who don't want their location known should not use the internet. anyone that parinoid should keep their head. Giving out critical personal information such as SSAN, banking and credit account numbers, etc is certainly illegal. But I don't see the harm in knowing what city someone is at.

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

if you want to read the 3d line, or any other line, in a file, just count the lines as they are being read and stop when you get to the line you want. You have to read text files sequentually -- from start to finish. If you don't know how to read a file then search the code cnippets for examples because I know they exist there.

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

line 11 may or may not work even though it would appear to us that it should. The reason is because many floats can not be represented exactly in memory due to the way IEEE math works. The best you can do is check for a range of values instead of an exact value.

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

suppose ,if u do an addition in c++ , where the addition opertor will be stored in a program

that's a pretty ambiguous question -- c++ has lots of addition operators and you can create your own. please post an example of what you mean.

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

pls send me a sample program with syntax in c++ so that i can study the program.. pls help me.. i am just a beginner and using c++ just 3 days ago. i hope you understand.. thanks..

That's a pretty complex assignment for someone who has only been studying c language for three days. If you are learning on your own you should start at the beginning of the book you are reading (you ARE studying a book aren't you???) and not in the middle.

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

In your example if you enter "205" you will get nothing because there are no lines that contain "205" :) But I understand what you mean anyway.

>>pls include the codes
Please first post your code to show us the effort you are making to solve the problem.

I would read the file one line at a time using fgets() function. Then you can use either strstr() to see if the line contains the search string, such as "205" and if it exists print the remainder of the line.

Code the problem one small step at a time to help from getting overwhelmed with the assignment. First, write the program that just opens the file. Get that to compile and work correctly. Then add to it the code needed to read each line using fgets(). Once that works you can continue with the reset of the assignment.

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

>>Hi all...my first post here...WOOHOO!! Ok...now to the meat of the question

Welsome to DaniWeb.:) Hope we see a lot more of you here and there. Please visit the Coffee House --> Community Introductons and tell us about yourself.

maybe you should read one of the pointer tutorials you can find on the net.

>>Can someone tell me how they finally "got it"?
through lots and lots of practice and experimenting.

>>What exactly is the difference
The difference is passing a single character or the address of the first element in the array. The star passes the first character in the array, while without the star passes the address of the first character.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
while (datafile)
    {
        datafile >> row >> col;
    }
    if ( row>=0 && row<Size && col>=0 && col<Size)  // if legal row-col
      Grid[row][col] = true;

In the above code you need to move that if statement to be within the while statement. As it is, your program reads the whole file but does nothing with the numbers.

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

do the assignment one step at a time. First think about what data items you want to put in the structure. What kinds of things do you want to know about each lecturer? Maybe you need his/her name, lecture date/time, class number, etc. Then crete the structure with these items. If you don't know how to do that you should look in your textbook for how to create one -- I'm certain you will find it. Then you should compile your program to see if your compiler complains about what you did.

If you can't figure out how to correct the compile errors, post us back with the code you wrote and the first few compile errors.

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

same answer as given in your thread 4 days ago, and it has not changed since then.

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

what operators? please post code that is giving you problems and your compiler's error message(s). iostream operators are in iostream header file.

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

there is no use for iostream.h because it is obsolete. use iostream instead (without the .h extension) assuming your compiler supports it. Old compilers such as original Turbo C++ may recognaize iostream.h.

It defines the c++ iostream classes -- output text to the console monitor.

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

you are right -- I didn't read the expected outcome, which is impossible. There is no solution that will give that outcome.

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

any conditional statement that is either true or false. for example if you were asked to enter either 'Y' or 'N' (Yes or No) then the statement might read

if( answer == 'Y')
{
   // true statement
}
else
{
   // false statement
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its not the compiler but the touch screen device driver. Is this for a PC or wireless? touch screens on a PC are all different so you will have to read the manufacturer's programming documentation to find out how to interface with it. Its been about 10 years since I programmed for them on a PC so technology has probably improved. If you mean wireless device then you don't have to do anything because the os will convert it into normal cursor events.

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

Hi

I tried making two static libraries each containing a single object file (abc1.C and abc2.C).
and libs: lib1.a (with abc1.o) and lib2.a (with abc2.o). Both the C files include the same header file and access the same variable "global".

I access this variable from both the files and find that a single copy of the variable is used , since a increment to variable "global" in one is seen in other file also.

I have declared the variable global as
int global;

Now everything is working perfectly.

Still do i need to declare this variable as an extern ??? Why am i not getting the multiple declaration error ???

Thnx

If you declare variables with the same variable names in two or more program units and the variables are of the same type, some compiler will combine them as if one was declared with the extern keyword. If you don't want that behavior then use the static keyword and each program unit will have its own copy of the variables.

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

I have a secret to tell you if you promise not to tell anyone else -- I don't like American footfall either. :eek: European football (we call it soccer) is a lot more exiting to watch, but we don't get much of it over here.

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

you should never actually declare variables in header files because if you have two or more *.c files that include that header file the compiler linker will issue duplicate objects errors (or something like that).

To get around that problem, in header files use the extern keyword, as in bala's example: extern int itemp; Then in ONE and only ONE *.c or *.cpp file declare it again but without the extern keyword. This will actually create an instance of the variable.

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

I had that same question some time ago and was told that templates can't be exported in a DLL. So I just use a pragma to disable that warning because the class will work anyway. #pragma warning(disable: 4251)

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

search the Code snippets for fopen because there are several example, such as this one.. If you read the docs for the fopen function it will show you which flags that are needed to actually create the file first if it doesn't exist.

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

here is an example. but maybe someone else can tell you how to do it with c++ instead of sprintf

float n = 123.456789;
char buf[20];
// format for 2 decimal places
sprintf(buf,"%3.2f", buf);
cout << buf;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try setw() or setprecision() in <iomanip> header file. There may be other ways I don't know. I like sprintf() for that better because its easier to use.

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

it is possible you could use a default constructor to set the fields of your object:

struct proceso
{
    char name[20];
    char memory[10];
    char time[10];
    char files[10];

    //constructor
    [b]proceso();[/b]
};
//Function Definition
proceso::proceso()
{
    strcpy(name = Doom3);
    strcpy(memory = 1212);
    strcpy(time = 14);
    strcpy(files = 2);
}

The constructor will set the according attributes for each new creation of an instance of the 'proceso' object.

that constructor is totally wrong. you need to compile code before posting to make sure it will work.

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

anyone got anything for me

don't be so impatient. I'm watching TV (House) at the moment

cin >> movie;

don't use that. use getline() function instead

when movie is std::string

getline(cin, movie);

or when movie is char array

cin.getline( movie, sizeof(movie));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why did you not post function insert() ? Is that the function you have the question about?

if you want to copy one structure into another you can use memcpy() function to copy everything in one bang.

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

please post code because we have no clue what you did

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

I believe TC3 compiler supports dos.h and I think it includes _dos_findfirst() and _dos_findnext(). Here is an example program.

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

replace the 6 with a star then put the variable in the parameter list

sprintf(blah, "%c%-.*s%c", QUOT, 6, varName, QUOT)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sanjay: what is the purpose of your post? did you forget to post some comments ?

hi dani
i am sanjay pleseas send the problam in c lang. my email.sit

The program is already C language. :rolleyes:

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

If you download the source code in that link I posted it will show you how to get the processes. Getting the process list is NOT MFC. The part of that project that uses MFC is displaying the results.