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

The variable name in the parameter to the print() function is NOT the same as the variable name declared in the class -- the name in the parameter will override (hide) the one declared in the class.

If you want to use the variable declared in the class then do not specify a parameter to print(). Just simply this: void print()

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

The c++ compiler/IDE in the article is no longer recommended -- Dev-C++ too old and obsolete. Either of the following free compilers/IDEs are now recommended
Code::Blocks with MinGW compile
VC++ 2010 Expess

Here is a tutorial for introduction into MS-Windows GUI programming using pure win32 api functions.

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

They are identicdal in terms of speed and memory consumption. You can always substitute a while loop for a for loop, but not the other way around. The for loop is preferable when you know exactly how many loop iterations there will be. The while loop may be necessary when the exact number of iterations is not known. Otherwise except for the syntax the two loops are the same.

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

Help you do what?? Instead of begging people to do your homework for you why don't you try to do it yourself, post what you have tried, and then ask specific questions about what you don't understand.

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

>>void print (first1);
Just like arguments to any other function you have to tell it what kind of objectg first1 is -- such as void print (Gnode* first1);

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

>>I've been addicted to postahol for going on 15 days now with no end in sight

Yooo. I've been addicted to DaniWeb for over five years now. And my post count shows that I too am a postaholic. AFAIK there is no cure for it except for death.

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

>> dont really know how the functions in c works
Then what you are attempting to do is waaaaayyyy over your head. Begin by learning C language -- read some tutorials and/or books. Then in a few days, or maybe a month, you will know enough to be able to fix those errors yourself.

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

>>i have c compiler so can i use it or i need c++ compiler and where can i get it

Depends on the C compiler you are using. Most modern compilers will compile both C and C++, depending on the file exten. *.c is normally compiled as C code while *.cpp or *.cc is compiled as c++. But you will have to test your compiler to find out how it behaves.

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

@firstPerson: that only works if the length of the string < 160 characters, and the cursor is at the beginning of the line. It won't work if there is already some text on the line.

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

"a" is a pointer to the letter 'a', it is not c++ class std::string. You can only use the + operator on std::string

std::string a = "a";
std::string b = "b";
std::string c = "c";
std::string text = a+b+c;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Some people use the code tags button, but I do it the hard way and just type them in

[code]

// your code goes here

[/code]

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

>>I just need to find a computer somewhere that I know hasn't already had the vc++ redistributable installed on it already

That should be quite easy -- just do a fresh install of the Windows operating system.

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

Signature spam... Still waiting for them new rules ;)

Don't hold your breath while waiting for that :)

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

An example of a fake signature is what the mods snipped from your post. It consists of one or more links.

Click the CONTROL PANEL link found at the top of evey DaniWeb page. On the left side of that page you will see a list of links, one of them says "Edit Signature". You can put all the links you want in your signature as long as they don't violate any other rules, such as porn.

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

Do you know how to READ? I assum you do since you know how to write (this thead). Read the DaniWeb Rules, which you should have done when you joined.

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

Replace cout with printf()

Replace cin with scanf()

Replace ofstream and ifstream with FILE*

Replace fin >> with fread() or possibly fgets(), depending on what is being read.

Replace fout << with fwrite(), or possibly fprintf(), depending on what is being written.

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

You need to start learning Windows Forms programming, e.g. either C++/CLR, C#, or VB.NET. That program can be written in any of those languages. You can also write it with just C, but it will be pretty difficult and time consuming.

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

You can hide the console window if you want to. In MS-Windows you have to use win32 api functions to do it.

#include <windows.h>

int main()
{
   HWND hWnd = GetConsoleWindow();
   ShowWindow(hWnd,SW_HIDE);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post the section of code that is used to write to the Component2-obs.txt. The code you posted does not tell us enough information to answer your question.

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

>>As s thing that its better to not use any database just bec of the person who will gonna use it ,maybe he dont have install sql or something in his/her computer that way the use just file.

You could use SqLite, which is completely embedded in your program and does not require any installation.

How to store the data should probably be the least of your problems. How do you plan to altert the user when an appointment time is up? Do you plan to pop up a message box over the top of whatever he is doing at the time, such as in the middle of playing a game and beating up the bad monster? What will happen if the computer is turned off and the alert is missed?

You need to do a lot of designing on this program before you even think about coding the first line. Write down your ideas on paper, or in a text document.

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

I just gave you more rep to see if that would change it, but that didn't help either.

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

This is one way to print only 80 characters on a line. I'm sure it could be better optimized, but I just don't feel like taking the time to do it. And it does not do word wrap like an editor would do, then 80 characters is met it just goes to the next line. If you want word wrap then you won't get 80 characters on every line without doing other fancy stuff, such as adding extra spacing between some words to force 80 characters (like newspaper print columns).

int LineLength = 0;
while( getline(f,s) )
{
   for(int i = 0; i < s.length(); i++)
   {
       cout << s[i];
       LineLength++;
       if( LineLength == 80)
       {
          cout << '\n';
          LineLength = 0;
       }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes it should. I recall Microsoft has a similar problem at one time with vc++ 6.0 compiler -- the problem was in a header file which they eventually fixed.

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

Repost your question here -- it is specifically for mac

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

>>How this while is executed?
Its an infinite loop because fgets() never returns EOF. fgets() returns NULL when it reaches end-of-file

tux4life commented: Exactly :) +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

don't know, unless its because you missed a \ in line 1 just before My Documents.

VC++ 6.0 is a very very old compiler that may, or may not support that import statement.

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

if you are using read() to read the data, then immediately call gcount() to get the number of bytes that were read. tellg() will only tell you where the file pointer is, not how many bytes were read.

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

getline() does not add the new line character to the end of the string, so if you display the string don't add endl or '\n' after it.

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

A solution is actually even simpler than what David suggested above. But I think the OP's instructor wants him to use that c++ class he posted. He will have to use an array, or vector, of those class objects. IMO that's really a dumb way to solve the problem, but the OP probably has no other choice.

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

>> I'd like to use char arrays for this, not c strings if possible.

They are the same thing in C language.

If you want to keep all the tokens (or words) in memory for all lines of the file then just generate a linked list of them.

struct token
{
   struct token* next;
   char* data;
};

Now just allocate new nodes of the above structure and allocate memory for data then copy the return value of strtok() into it.

Warning! The following code has not been compiled or tested. I just posted it to give you an idea of how it can be done in C language.

#include <stdio.h>

int main()
{
   struct token* node;
   struct token* tail = 0;
   struct token* head = 0;
   char iobuf[255];
   char* ptr;
   FILE* fp = fopen("filename.txt","r");
   if( fp != NULL)
   {
        while( fgets(iobuf, sizeof(iobuf), fp) != NULL)
        {
            ptr = strtok(iobuf,' ');
            while(ptr != NULL)
            {
               node = malloc(sizeof(struct token));
               node->next = 0;
               node->data = malloc(strlen(ptr)+1);
               strcpy(node->data,ptr);
               if( head == NULL)
               {
                   head = tail = node;
               }
               else
               {
                   tail->next = node;
                   tail = node;
               }
               ptr = strtok(NULL,' ');
             }
         }
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

make sure you include stdio.h and that you add main() function. The code in your link is not a complete program.

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

May be this could fix your problem , run it .
I tried it worked, I cant figure out any other alternate way to it in C

#include<graphics.h>
#include<conio.h>
#include<stdio.h>

int main()
{
int ip;
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
cscanf("%d",&ip);
getch();
printf("Input Output \n");
printf("%d    %d",ip , ip);
getch();
return 0;
}

Let me guess -- you are using Turbo C or Turbo C++ compiler. graphics.h is obsolete and not supported by any modern compiler, although there might be a 32-bit port of it that I am not aware of.

And the OP has already stated that he is using *nix, not MS-Windows. So that code, like the one I posted, is of no value to him.

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

Line 4: remove that semicolon at the end of the line. That is what is causing the error message.

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

you can not write and read binary files with structure members that are std::string. why? One reason is that sizeof(std::string) does not include the actual characters but just the size of the c++ class. The sizeof(std::string) is the same regardless of how many characters are managed by that class.

Replace the std::string with character arrays and it should work.

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

Oh, you don't mean "produce" -- the compiler does not produce any code, native or otherwise, except for the templates when you create a project. What you are asking is how to mix managed and unmanaged code. Here is an article on MSDN which should apply to all .NET compilers.

Here is another article that shows how to mix them in c++/clr program. How to use that in Windows Forms? I have not tried it but I assume the technique might be very similar, if not identical.
[edit]Note: I tried that technique and vc++ 2010 express didn't like it. The article was written in 2003 and probably very obsolete.[/edit]

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

Although that may have answered your question, I hope you realize that article is 8 years old and we now have Windows 7. I think w2K was the first Microsoft operating system whose hard drive didn't crash often. I don't think I've had a problem with NTFS since then (knock on wood).

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

what do you mean by "native code"?

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

You can not use printf() in a MS-Windows gui program. Why? because there is no console.

>>have tried passing the name of the array to the function but I looked around and found youd could pass only string to the function
MessageBox parameters are character arrays, not c++ strings. There are two versions of MessageBox() -- one that takes char* and the other for UNICODE that takes wchar_t*. If you are compiling for UNICODE then you will have to surround string literals with _T( or _TEXT( macro. For example: _TEXT("Hello");

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

Here is a guy whom I suspect wishes he had used a holster.

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

5.2: Every c++ statement ends with a semicolon. Commas are only used to separate multiple statement on a line.

For example:

int a;
int b;
a = 0;
b = 1;

The above could also be written like below. Which one to use is up to you -- the compiler doesn't care.

int a, b;
a = 0, b = 1;

Double quotes are used to enclose strings, single quotes are used to enclose a single character

string World = "Hello World";
char c = 'H';

The compiler treats everything within double quotes as a null-terminated string, or character array. So that second statement char c = "H"; is wrong and will produce a compiler error message.

>>*what is the difference between these?
The first is a numeric value 64. The second is syntax error because you can not have two or more characters within single quotes.

A string literal is a set of characters within double quotes, such as "Hello World". A string object is just the name you give to the array string World;

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

My guess is that the difference is due to running the program on a multi-threaded operating system such as *nix and MS-Windows. The operating system is doing a lot more things than just running your program.

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

One way would be to make an array of valid strings then loop through that array

string valid[] = {"abc111","abc112","abc1113", ... };
bool ok = false;
for(int i = 0; i < sizeof(valid)/sizeof(valid[0]); i++)
{
   if( userdata == valid[i])
   {
      ok = true;
      break;
   }
}

if( ok == true)
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 23: sizeof(& file_F));

That is returning the size of a pointer, not the structure. Remove the & address operator.

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

DLLs can be scarry, and even down right dangerous. Its called "DLL Hell" because installing a DLL on a computer can often cause other programs to crash or not work right. Installation prograsms have to compare version information in DLLs before upgrading to a different one.

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

If your project contains lots of *.c and/or *.cpp files with lots of includes that are common among all of them then using precompiled headers will help speed up the compile process. How to do that, if it can be done at all, will depend on the compiler you are using.

But 16 minutes isn't really so bad -- in 1985 I used to start a program compiling then go read a book or do something else for two hours.

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

Real-world use of DLLs??? Every function in the win32 api are contained in DLLs. Just look in your compiler's install directory and you will find lots of DLLs. Same in c:\windows directory.

How to write a DLL of your own is another matter, and a subject for larger discussion. There is lots of information out there, but most of them use very old comilers such as vc++ 6.0. Here is one that uses current vc++ compiler.

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

Here in USA men also don't really like successful women. There was an article on TV a couple years back that studied the love live of successful single women -- they have a really hard time finding men to date probably because men are afraid of them. It seems men do not want a woman who is more successful than he is.

And women also find a certain amount of discrimination even at the M.D. or Ph.D. level. I had a woman family doctor who once told me that she wanted to be a surgeon but was denied because they already had all the women surgeons they wanted.

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

You do not need to create a database(Although this is a viable option). MFC has a CArchive class and a serialize function which can be used to create a binary file which will save your data for you(Can load back in etc...). Research it.

You just contridicted yourself. As I said before a database can be as simple as a text or binary file. And IMHO CArchive is terrible for writing normal binary files, and completely useless for writing text files. Better off using fstream, unless you need to serialize MFC windows class objects.

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

>>what are DLL's
Libraries of functions that are shared among all processes and threads which greatly reduces the amount of memory that program consume. If it were not for DLLs every program on your computer would be at least tripple its current size.

>>what exactly is a kernal
The operating system.

>>would a regular programmer ever right a kernal program
They could, but not very many do. I have programmed since 1985 and not once did I write a kernel program or extension. If you want to write a device driver for a specific piece of hardware then you will need to write a kernel extension for it. There are, of course, other reasons to do it, but that one is probably the most common one.

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

Yes it was the driver that caused the link error and the overloadede << operator. I also made the class friend line public, but that didn't fix it either.