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

post the structure or class Partita. We have no clue what you are talking about without that information.

If that structure contains pointers, then you have to write out their values separately, and you will have to design the file format in such a way that the Partita structure and values of all pointers can be read back.

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

use vector

#include <vector>
...
int main()
{
    vector<Thing> things;
    Thing oneThing;
    // add OneThing to the vector
    vector.push_back(theThing);

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

Visual Studio 2008 Professional Version. You can't download it from anywhere but you can buy it from lots of places.

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

I wonder a little about this MFC.
In VC++ 2008 Express Edition, is it possible to do this here.

No. That version does not support MFC. You have to get the Pro version to do that.

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

That is called a Splitter Window. The only way I know how to do it is with MFC, but I suppose it can be done with pure win32 api functions. Don't know about wxWidgets either.

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

If you just want to compare the two lines you don't need to split them into words. Just compare the entire line

std::string line1;
std::string line2;
getline(myfile, line1);
getline(myfile, line2);
if( line1 == line2 )
{
    // the two lines are identical
}
Alex Edwards commented: Very true =P +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this is a c++ program, so use c++ classes

#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<string> arry;
    ifstream in("filename.txt");
    string word;
    while( in >>  word )
    {
            array.push_back(word);
   }
}

But, in your example while (myfile>>a[names]) should be while (myfile>>a)

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

move your project to a folder that does not contain spaces, such as c:\dev-c++\source

Nick Evan commented: Making the rep count as requisted by OP :) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program compiles/links ok for me. Instead of powerprof.a you have to link with libpowerprof.a.

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

The trick is to use fixed c1 << fixed << setw(6) << Total;

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

You have to make a project then it will work. Just create a new project and copy the file into it.

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

>>I checked about SetSuspendState() in DaniWeb, and googled it, but came up with nothing.
Not supprised about DaniWeb, but google had lots of links

Always either search MSDN or google for all win32 api functions, and they will give you detailed information. Here is the information you need.

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

Your program contains millions (maybe even billions) of other errors. What line number are you talking about.

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

you also have to change line 40 to be the correct parameter type.

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

line 323: According to line 17 length_iter() requires an array of characters. passijng *_string only passes a sincle character, not the entire array. And rstring is not an array of characters, but a reference to a single character.

I think what you want is this:

void SString::operator+(const char* rstring)
{
	//string temp();
	int len = length_iter(_string) + length_iter(rstring);

<snip>
}

Or you might also want this overloaded function

void SString::operator+(SString& rstring)
{
	//string temp();
	int len = length_iter(_string) + length_iter(rstring._string);

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

Access is ok for one or two user database, but anything beyond that is just too much. For multiuser you need something like Microsoft SQL Server, or MySQL. For student projects Microsoft Access is IMO an excellent choice.

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

Lines 27 and 28 can only appear in ONE *.cpp file -- doesn't matter which one. Remove those lines from the header file.

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

No -- the name of the file has little, if any, relationship to the class name(s) that are in it. The name of the header files doesn't have to be the same as the class thats in it.

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

It will help to know what the error messages are. I'm supprised those compiled with a MSWindows compiler. You can't leave both dimensions of the arrays unspecified

void printOctets(int octets[10][], char []); 
void printInterval(int suntwk[10][], int brdc[10][]);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

string.h is the name of a standard C header file. You should name your header file something else so that you can get the functions that are in the standard string.h header.

Its not necessary to pass all those parameters to those string functions, because the string class already knows about the functions. And you don't need private functions that can be easily done in the public functions, such as str_length()

int str_length()
{
    return strlen(_string);

Thats all you need in the public function.

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

you have to use the function in string.h, such as strcpy() to copy a string, or strcmp() to compare two strings.

post the two classes so that we can be more specific.

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

you have a dvd class that contains string objects. Why are you writing your own string class when there is a perfectly good std::string class?

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

Since CountVowels() returns an integer, then the OUT parameter must be a pointer int CountVowels (char text[], counter_t* Count); I don't know what integer that function is supposed to return -- certainly not a counter_t object because that isn't an integer. If you make the second parameter a pointer as * showed above then you must also change the dot notation to pointer notation case 'a': Count->a++; break;

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

sql Do you mean Microsoft SQL Server, or do you mean the SQL language?

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

Thanks, I'll try that, but it'll stop it for both objects.

Of course it will. That's not a problem though. What you want to find out is the value of numDay -- is it 0 based or 1 based ?

And this is a good exercise in learning how to use the debuger.

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

Use your compiler's debugger, put a breakpoint on that function, and find out why it prints the wrong day of the week. My guess is that dayNum is wrong -- Sun should be 0, but dayNum may use 1 for Sunday.

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

Your first code prints c++ for me using VC++ 2008 Express. What compiler are you using?

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

>>Somehow seems as if the "stdio.h" doesn't recognize the type File
That's correct because there is no such thing in stdio.h -- its FILE (all caps).

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

>>Here's a correction
I'm afraid not. Line 38 is wrong.

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

1) I would create a structure that holds the count and string for each word

struct words
{
    std::string word;
    int count;
}

Now have a vector of these structures vector<words> wordList; Now when you get a word, search the vector for occurence. It its already in the vector just increment the counter. If not, add a structure to the vector.

as for using strcmp() -- dump it. You don't need it because you can use std::string's == operator to determine if the two strings are equal. And its not necessary to sort the words if you use my suggestion above.

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

Read in your textbook or online about the parameter to ins.get() -- it takes a pointer and you are passing a char. Whenever you get an error like this one you need to look up the function in your textbook or google for it so that you can verify for yourself that you have the right or wrong parameters.

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

use getline() to retrieve the entire line as one string, then run it through the code I posted. instead of writing each individual string with cout put it in the array like you previously posted.

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

don't use strtok() on std::string objects because strtok() will put 0s in the string which will invalidate the std::string object.

The c++ way to achieve this is

int main()
{
    string str = "123 Mike November,12 1990";
    size_t pos = str.find_first_of(" ,");
    while(pos != string::npos)
    {
        cout << str.substr(0, pos) << "\n";
        str = str.substr(pos+1);
        pos = str.find_first_of(" ,");
    }
    cout << str << "\n"; // display the last word in the strihng

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

The win32 api function you want is SetSystemTime()

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

Sorry to tell you that the only way to add something to the beginning of a file is to completly rewrite it.

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

You need to use the pointer cout << " " << it->time; or like this: cout << " " << (*it).time;

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

>>or am i just exaggerating this thing?
You are misunderstanding the difference. The presence of a lot of member functions has nothing to do with efficiency. If you just want to use structures and pure win32 api then IMO write a C program, not C++.

MFC itself is pretty in-efficient. Its a handy set of c++ classes, but not very efficient. So to quibble about the difference of using RECT or CRect isn't really very productive. If your program requires efficiency and speed, then ditch MFC and use something else, such as wxWidgets.

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

>>first of then strlen only counts the characters in the first word of the line I put into console
The problem is your code, not strlen(). The >> operator stops accepting data from the keyboard when it encounters the first space or tab. All the rest of what you typed is still in the keyboard buffer. If you want all the spaces too then you have to use cin.getline() with character arrays or std::getline() with std::string.

Correcting that will also probably fix the other problem.

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

IMO use MFC objects when available. In the two cases you cited it doesn't really matter to the compiler, it just makes your program more consistent if you use the MFC objects.

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

how did you declare it in your vb program? what you posted appears to be correct. But you don't need both the *.def file and use of _dllspec(__export) -- all you need is one of them.

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

Because the pointer has not been initialized to anything. It just points to some random location in memory, which your program may, but probably does not, own. Before using a pointer you must initialize it to point somepace. For example:

int *pVar;
int number;
pVar = &number;
*pVar = 9;
William Hemsworth commented: beat me to it :P +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I suppose you could use the time functions in time.h

time_t t1, t2;
t1 = time(0);
t2 = t1
while( (t2 - t1) < 1) // one second
  t2 = time(0);

You might also check the Boost time functions

Alex Edwards commented: Interesting indeed! =) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how was the file opened? as text or binary? If binary then the next line character(s) depends on the operating system. In MS-Windows/MS-DOS you need "\r\n". *nix just "\n" and MAC "\r". If the file is opened in text mode then the operating system will make the appropriate translation of "\n" to whatever it needs.

I tried your three lines and it seemed to work ok for me. Opened the file with Notepad.exe and it looked ok (except for the Chinese characters). What editor are you using? If not English language then find out what it expects as line feeds.

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

This probably won't solve your problem, but ... Do you really need that vector? Why not just combine those two loops?

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

Did you try something like this?

#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

void foo(ifstream& in)
{

}

int main()
{
    vector<ifstream*> streams;
    for(size_t i = 0; i < 5; i++)
    {
        ifstream* in = new ifstream;
        streams.push_back(in);
        streams[i]->open("filename.txt");
    }
    foo( *streams[1] );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can use either sprintf() or strcat() to format the output file name. Example:

char outname[255];
char inputname[255];
char* ptr;

printf("Enter a file name\n");
fgets(inputname,sizeof(inputname),stdin);
strcpy(outname, inputname);
// truncate the extension
ptr = strchr(outname,'.');
if(ptr != NULL)
   *ptr = '\0';
// now add new filename
strcat(outname,"_res.txt");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't have ubantu, but Microsoft VC++ 2008 Express reports 1 for the program that jamthwee posted. The compiler stored -61 in that byte. crappy *nix :)

>>I'm sorry, but I'm a beginner C++ programmer to such a "noob" level I don't know what you're talking about

UNICODE is a standard way to use non-English languages in computer programs. The standard UNICODE character is wchar_t, not char. Under MS-Windows wchar_t is defined to be unsigned short while in *nix (the last time I heard) it is unsigned long This is because many languages, such as Chinese, use graphic symbols which can be accommodated by wchar_t. In order to compile for UNICODE you have to set specific flags in the makefile -- I have no clue what those flags are for your compiler.

[edit]Considering jamthwee's test I would not bother with the UNICODE described above. It appears to be a compiler issue.[/edit]

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

Please post example code. Are you compiling for UNICODE ?

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

you can't change the < operator to >, but you can change i to be greater than End and Step to negative, which I believe will accomplish the same thing.

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

cikara21: Huh? Is that supposed to mean something?