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

LOL I didn't think you guys liked it so much! I just thought it was a completely useless statistic that came with vBulletin by default. I'll consider putting it back :)

Useless -- yes. But its nice-to-know.

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

You could tokenize (strtok) by "<" and stick each piece into a vector or so... then get it's size().

That sounds like the hard way. strtok() embeds NULLs in the string, which might corrupt the std::string class.

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

>>Has anyone seen anything that does something like this?
just add '\r' to the print statement

int counter;
for(counter = 0; counter < 1000; counter++)
{
    cout << "\rcounter";
    Sleep(500); // 1/2 second delay
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well Yeah.....20 errors in total.....which includes an include file error??

Nope -- here are the errors I get. As you can see, the first error is about undefined symbol "printMenu". Fix that up and recompile. I'm not going to fix all the errors in this program for you -- that is for you to do.

1>c:\dvlp\tmp\lib_test\lib_test\login.h(31) : error C3861: 'printMenu': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(99) : error C2084: function 'int login(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\login.h(9) : see previous definition of 'login'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(138) : error C2084: function 'void printMenu(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\menu.h(7) : see previous definition of 'printMenu'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(159) : error C3861: 'login': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(179) : error C2084: function 'void viewFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\view.h(7) : see previous definition of 'viewFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(186) : error C2084: function 'void options(int)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\menu.h(7) : see previous definition of 'options'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(196) : error C3861: 'viewFile': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(208) : error C2084: function 'void createFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\create.h(9) : see previous definition of 'createFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(233) : error C2084: function 'void readFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\read.h(6) : see previous definition of 'readFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(249) : error C2084: function 'void exitScreen(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\exit.h(8) : see previous definition of 'exitScreen'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(258) : error C2084: function 'void editFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\edit.h(10) : see previous definition of 'editFile'

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

you use getline() to read an entire line that is terminated with '\n'. Then use string::find() to look for < and > characters as shown in previous example code.

Also note that ipfile.eof() is not needed in my loop because the loop stops on error or end-of-file.

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

why not just use getline() to read an entire line at one time?

std::string line;
while( getline(ipfile, line) )
{
   // blabla
}

I don't do html coding, but I think any given tag must be on one line, such as "<html>" can not be split between lines, so it doesn't make any sense to read the html file one character at a time.

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

We do not speak gobbledygook. Please explain with a better example and more explanation.

Generally, the only way to read the last item of a text file is to read the entire file.

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

Yeah I'm aware of that, Im talking about for example

2 executables

exe a and exe b
exe a will configure/edit values of exe b
exe b will retain them and use them will running self contained

That might work as long as exe b is not running while exe a is writing to the file. Running executables can be opened for reading, but not for writing.

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

This smells like homework, but I'lll try to answer them anyway.

>>Q.no.1: What is the difference between zero and null values?
In c++, none. Most compilers define NULL as 0. Traditionally programmers use NULL for pointers and 0 for numeric objects, but some programmers such as Dr. Bjarne Stroustrup (father of c++ language) never use NULL.

>>Q.no.2: If we have double data type then why we use long data types?
They serve two different purposes. long data types take up less memory and operations on them are faster. longs are just simply more efficient when decimals are not needed.

>>Q.no.3: How arrays make coding easy in C++?
because you can use loops to manipulate arrays, which means less coding then a bunch of individual data items.

>>Q.no.4: If we are given 1-dimensional array. How can we code through single dimensional array?

with a loop.

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

Its not possible to write to an executable file while it is executing -- the operating system will forbid it.

tux4life commented: That was an answer right to the point ! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We only close threads when it violates one or more of the DaniWeb rules. Its perfectly acceptable to post in old threads as long as the new posts are on-topic and contain relevant information.

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

probably something like this:

std::string str = "<html>";
if( str.find("<") != string::npos && str.find(">") != string::npos)
{
    // most likely an html tag
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

hey tell me is it like knowing more number of programming languages important..or rather mastering a few of them more helpful??

Its not like that at all -- there are very few things you can do in today's world if you are illiterate.

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

it <posts per day> could be figured out by doing the simple division yourself) .

Its not that trivial. For instance, my join date was Aug 25, 2005. So, how would you calculate my posts/day without first calculating the number of days between my join date and today? It would be a lot better to just let the computer do what computers do best and calculate the posts per day for us. I don't see why it would be so hard to put it between Posts and Blog Entries on the profile page.

verruckt24 commented: Exactly - Also I would be eager to know how many people actually do the so called trivial calculation. +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yup. For some reason Mod's refuse to use tags, they always use 4chan-style > quotes.
But they do give people infractions for not using [code]

[/code] tags...
Go figure :)

Those are two entirely different issues. DaniWeb Rules require code tags and for good reason, but say nothing about quote tags.

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

1) in login.cpp change #include <login> to #include "login.h" 2) in include.h, change #include <login.h> to #include "login.h" When surrounded by angle brackets < and > the compiler does not look in the project directory for include files. You have to put it in quotes to do that.

After you fix that you will get a lot of other errors.

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

See strtok(), a C library function. It may solve your problem.

http://www.cppreference.com/wiki/c/string/strtok

Nope -- will not help solve his problem at all.

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

your instructor is an idiot. Go immediately to another university.

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

The while loop is wrong -- don't need eof()

int number;
while( inFile >> number )
{
    // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but it closed after I input the random number.

Because you programmed it to do that. As ^^^ said you have to put something before the return statement to make the program stop and wait for you to enter something from the keyboard.

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

>>ask this question from yourself. I will going to save them
in the form of money and see the max what I can do ...

I saw those pictures 40+ years ago. There is really not a thing we can do to help them because the dictators in Africa don't want us to help them. Every time we (USA) send food over there the dictators steal most of it.

>>Think how much money that I can save if I change my bad food
habit ?
Don't bother because it won't help them. If you want to save money, that's find, but do it for the right reason.

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

>>PrintType(); // why? Mobil::PrintInfo calls it!
No it doesn't. Mobile::PrintInfo calls Mobile::PrintType. Base class can not call derived class methods unless they are implemented as pure virtual functions in the base class.

I have often seen need for derived class to call base class implementation of a virtual method, such as

void Advanced::PrintType()
{
     Mobile::PrintType();
     // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb.

>>what else??
Reading, Writing and Arithmatic. The three most important parts of your education.

Little in the last ten thousand years has altered our mental lives as much as the creation of reading, writing and arithmetic. These developments sprang directly out of the first agrarian revolution, which about 10,000 years ago began to transform humankind from hunter-gatherer to farmer. The adoption of crop cultivation techniques and the domestication of animals led to major social changes. These included denser populations, hierarchical societies with ecclesiastics in the top echelons, and the development of non-agricultural crafts.

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

extern is not absolutely required, but does clarify it a bit IMO.

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

The general method of using multiple *.c files is to put the function prototypes in a header file, then include that header file in all the *.c files that need the functions. If you look at a couple standard C header file that are supplied by your compiler you will see that they only contain #defines, typedefs, and function prototypes.

Here is a simple, brief example. You need to compile both *.c programs then link the two object files in order to get the executable program. Exactly how to do that depends on the compiler you are using.

// foo.h
extern void foo();
// foo.c
#include <stdio.h>
#include "foo.h"

void foo()
{
   printf("Hello World\n");
}
// main.c
#include "foo.h"
int main()
{
    foo();
}
tux4life commented: Nice explanation ! +1
Salem commented: Good job +29
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Microsoft has online MSDN, or you can get it on DVD for a few hundred dollars. Otherwise, google is as good as it gets. Microsoft used to publish the functions in books that came with the compiler, but they stopped doing that about 15+ years ago when electronic books became popular.

You can, of course, always go to your local bookstore and buy a copy of the reference books.

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

Many header files in the standard c++ and C libraries are pretty darned hard to read, so I find it often useful to google for the filename. For example if you want to know what's in the fstream header file then just google for fstream.

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

zip up your entire project folder and attach it so that I can see what the problem is.

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

line 217-354: convert that to a switch statement. And next time user [code=c] ... [/code] code tags

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

Here are some pros and cons for using MS Access database. The author listed 11 pros and 15 cons. IMO the biggest reason for not using it is database table/file corruption that can occur with large tables and/or too many users.

But is you only have a couple users and fairly small number of rows in the tables, Access might be a good choice for you.

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

So -- where is <login> header file? Is that the same file you posted previously but as login.h? If it is, it belongs in the same folder as the other *.cpp files in the project.

>>Now, Do you suggest to change all my .h file to .cpp?'
Not at all -- only the ones with executable code.

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

Make the function in MobileAccount a pure virtual function so that it has to be implemented by derived classes

class MobileAccount
{
....
protected:
   void PrintAccountInfo() = 0; // <<< pure virtual function
...
}

Then MobileAccount class doesn't have to know who implemented the function.

void AdvancedAccount::PrintAccountInfo() {
	PrintAccountInfo(); // <<<< here
        PrintAccountType();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just as well you got that error because NEVER EVERY UNDER NO CIRCUMSTANCES put executable code in a header file (inline functions are the only exception.) Take that function out of that *.h file and put it in a *.cpp file. Then compile the two *.cpp files separately and link the object files together. Exactly how to do that will depend on the compiler you are using.

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

It doesn't compile because it is missing { on line 3, not because of the // comments. Compiles fine with *.c file extension on vc++ 2008 express.

void f();
int main() //
{ // <<<<<<<<<<<<<<<<<<<<<<<<<<<
    f();
    return 0;
}
jephthah commented: i love when that happens :) ... except of course when it happens to me :( +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

shirish: Also be aware that, for Microsoft compilers, the functions in time.h do not work with dates prior to 1970. Here is a good article how to get around that on MS-Windows os.

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

Its been 8 hours now and you still have not started writing the code yet! All you have to do is get the two date/times as time_t object, subtract them. The result is the difference in seconds. From that you can easily convert to minutes, hours, days, years, decades or whatever you want.

To get the time_t object, first populate a struct tm structure with the date/time and call mktime(), which returns time_t.

The whole thing might has taken you an hour or so to complete and test. Instead, you have so far wasted 8 hours trying to get someone else to do it for you. Not very efficient use of your time.

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

Struct point is defined in the protected section of the class PS2Sprite, which means it can not be used outside that class. If you want to use that structure like you are doing then move its definition outside any class.

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

There is no standard function for that -- you will have to write your own. You could have written it yourself in the time that it took for me to post this response (5 hours).

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

Alas, Visual C does not support // comments in C sources.
Change them to old (classic) C comments /* */

Nope. VC++ supports // comments in C code. I think its part of the C standards now, but wouldn't swear to it.

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

Welcome to DaniWeb

>>I am a christain and husband to one wife.
Do non-Christian's have multiple wives where you live :)

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

closed

Moschops commented: Incisive and witty. +9
markwiering commented: Why? Now we can't react anymore! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If I were to work on say an Instant Messenger project, and wrote the gui and event handling using wxWdigets, could I then use the windows API and use winsock to connect the two computers? Basically are API's interchangble in source code?

Try it and find out for yourself.

well thats not very helpful =(. I am just looking for a simple idea if anyone can give me one. Nothing super in depth

Perhapes if you read my original SIMPLE question, these subtle insults would not be needed.

As you see from these quotes, I did read your original post. It was you who started with the insults.

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

Isn't that what "they" say about programmers: we're lazy?

I've been called a lot of things in my life, but "lazy" isn't one of them. I would have taken only about an hour or less to find out the answer to that op's question, but he messed around for several hours trying to get someone else to do it for him.

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

You could just look at the APIs and see for yourself.

I suggested that too be apparently he is too lazy to do it.

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

why? because it would require more effort than one would normally expect out of a free programming forum. This forum is for asking, discussing, and answering programming questions, not for providing free computer programming. For that you will have to pay just like everyone else that wants people to write programs for them.

Almost everyone here at DaniWeb are unpaid volunteers. None of us get paid for helping others, so don't expect us to do something like what you want for free.

Since you like to bump this thread so much I'm going to close it to prevent you from doing that again.

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

Would an if and else-if statement work as well??

No because you need a loop to look at all the items in the array. You will need an if statement inside the loop. Something like this:

int j;
bool found = false;
for(j = 0; j < i; j++)
{
   if( array[j] == random_integer)
   {
         found = true;
         break;
   }
}
if( found == false)
{
    // add new item to the array
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

before adding the new number to the array you need to search the array to see if its already there. A simple for loop will suffice.

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

well thats not very helpful =(. I am just looking for a simple idea if anyone can give me one. Nothing super in depth

The best way to learn how something works is to try it out yourself and test it on your own computer with your own code. If you want to every program professionally then you will have to learn how to do your own experiments to see what works and what doesn't.

If you want a simple answer then: yes you can probably mix the two, and no they are not interchangeable.