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

That link already contains example code. If you don't understand it then write your own little program and play around with the format string to see what they do.

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

>> I know but how do i implement this

Simple, just look at the delete flag

while (Read next record)
{
   if( delete flag not set)
      Print record
)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use strftime() and you can format the date any way you want. All you need is a struct tm object. And you can get that from either localtime() or mktime()

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

>>void input_data (string first_name, string last_name, string street, string city, int zip);

That is not call by reference -- its call by value. This is call by reference
void input_data (string& first_name, string& last_name, string& street, string& city, int& zip);

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

The whole purpose of pseudo code and flow charts is to organize your thoughts. Its like writing a draft in English 101 class. Learn to write pseudo code and the rest will come a lot easier.

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

>>But it's against the rules to have multiple accounts

That shouldn't apply to Admins. You can do anything :)
Besides, there are members who do have multiple accounts.

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

Don't you have two different accounts that you can use? Create your own news story and use it for your testing with two or three different accounts.

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

I get the button when I click on "New Posts" in the purple ribbon at the bottom of the screen. Maybe you need to post in one of those news items then wait for someone else to post in order to see the button I mean.

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

Help you do what exactly? Write the program for you? No in this lifetime.

I assume you have a choice of whether you want to store those user names and passwords in a password text file or just hardcode them in your program. The instructions was ambiguous about that.

Create an infinite loop that prompts for user name and password, checks the list that you were given. If a match is found then exit the loop. Otherwise if no match was found let the program loop back to the beinning of the loop and ask again.

WHITE_BOLT commented: no help +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It takes me to the original post of the thread.

I suspect you are clicking the wrong button. The one I'm talking about has this description:

"You have posted in this thread and there are new posts: Click icon to go to your first unread post"

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

why do instructors insist on teaching while( !in.eof()) instead of while( getline(in, line) ) ? eof() doesn't work like that and cause the while loop to loop too many times.


You should probably attach the input file rather than trying to paste its contents into the editor because the editor. The file contents you posted does not contain tabs -- just spaces.

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

Not harsh -- tough love :)

Normally you will want to break down the problem into its simplest parts, then code them one at a time -- divide and conquer style. Compile and test each part before going on to the next part. The worst thing you can do is to write 100 lines of code without compiling it. Compile and fix compile errors frequently. When you get several compiler errors, fix the first one then compile again to get a new list of errors. Fixing one err may actually fix a million other errors.

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

>>while (!(cin >> choosefunction))
Wrong. Use a switch statement instead of that while statement

cin >> choosefunction;
switch(choosefunction)
{
   case '1':  
        SecondMenu();
        break;
   case '2':
        ThirdMenu();
        break;
   // etc. for each 
   default:
      cout << "What an idot you are\n";
      break;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On which line did that error occur? Your compiler should have told you.

Is Subdomain an integer? I thought it was a string or chracter array.

Did you include <string> header file?

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

That's about the only way I know of to do it.

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

This is the basic idea, you might have to modify it to suit yourself, such as do error checking and trim whitespace from end of the mac address after extracting it from the line.

std::string foo(std::string search)
{

std::string line;
ifstream in("filename.txt");
while( getline(in, line) )
{
   size_t pos = line.find('\t');
   std::string mac = line.substr(0,line);
   if( mac == search )
   {
      return line.substr(pos+1);
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How to start will depend on the problem. They all start like this:

// include header files here

// declare function prototypes (if needed) here

int main()
{
   // put code here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8: This is not vb, -- its c++ and you can not concantinate strings like that

std::string command;
command = "select value From domain_data where SubDomain = '";
command += Subdomain;
command += "' And key = 'AMTConfigPath';";
returnbuf = db.execScalar(command.c_str());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't use that compiler, but I know there are flags that will make it spit out more warnings and errors.

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

>>@AncientDragon, have you experienced anything of that sort as explained in that link

I have never experienced a problem in MS-Windows with using fseek() and ftell() to get the file size of a binary file. Even if the file had trailing null bytes I don't see how that would invalidate the return value of ftell() because those trailing null bytes are part of the file.

But I suppose there could be some obscure file systems where ftell() might not work. That doesn't mean it should be prohibited for everyone in the world to use it.

There are some embedded systems on which ftell() and other FILE* related functions won't work. I was writing C++ programs for PocketPC os and the Microsoft compiler (eVC++ 3.0) did not support FILE or any of its associated functions. Nor did it support any of the STL classes, such as fstream, iostream, string, etc.

I wrote a small program to find out how VC++ 2010 Express got the file size for _stat() function. It calls FindFirstFile() to get the file's info. I'm not sure how FindFirstFile() gets its information, but most likely by calling other win32 api functions instead of using ftell() or lseek()

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

>>That being said, to call this a violation of a right

I don't recall anyone saying that in this thread, but if I missed it and they did, then they are dead wrong. A base (or post) commander has every right to not allow something to be sold in the BX/PX, just as WalMart, ToysRUs, Target, or any other company has the right not to sell something in their stores. This is not a US Constitutional issue. And AFAIK no one is going to go door-to-door searching for people who have bought that game from somewhere else and are playing it in their homes (or barracks). That would be an invasion of privacy.

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

>>using hbg_cmpsc122::Fractions;

Fractions is not in namespace hbg_cmpsc122 because you have misspelled the class name. Pay closer attention to spelling and capitalization -- fraction is not the same thing as Fraction.

What compiler are you using? I'm on MS-Windows using vc++ 2010 Express and I get lots of error messages and warnings.

Also, delete line 4 in Fractions.h.

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

>> fflush(stdin) -- that is non-standard C code which is not supported by very many compilers. If you compiler does, ok, but don't expect the program to compile by your instructor's compiler. And that might get you a lower grade.

move line 25 up to line 18 so that the menu is displayed before testing for invalid input.

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

maybe you are not opening the file in binary mode. This works ok for me

int main()
{
    int *parray = 0;
    int ay[] = {1,2,3,4,5,6,7,8,9,10};
    int size = sizeof(ay) / sizeof(ay[0]);
    FILE* fp = fopen("filename.dat","wb");
    fwrite(ay,sizeof(int), size,fp);
    fclose(fp);
    
    parray = new int[size];
    fp = fopen("filename.dat","rb");
    fread(parray, sizeof(int), size,fp);
    fclose(fp);
    for(int i = 0; i < size; i++)
        cout << parray[i] << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why are you using low-level file i/o?? Just use FILE* and all will be ok. The only reason to use open() is when the compiler for the target operating system doesn't have FILE* and associated functions.

But to answer your question, lseek() returns the file offset.

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

I wouldn't bother learn 16-bit asm, go directly to 32-bit so that the program can use whatever memory is available on the computer. It's also somewhat easier -- with the flat memory model it is not necessary to change the value of ds segment because all data is in the same segment.

As for assemblers: either masm, nasm or tasm.

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

If your program has to do file i/o or displaying something on the screen then it has no choice but to call win32 api functions to do that. 32-bit programs can not access hardware unless its a kernel level program.

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

There are pros and cons to that.
Pros: the program will be a lot faster at startup

con: the file can't be easily changed. If you need to change something (i.e. add or delete info) then you might have to write a small conversion program that converts the data from from old format to new.

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

line 116: variables x and y have not been initialized to anything.

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

So, just typecast it to time_t

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

You are right, and that's exactly what I meant. It is not possible to use sizeof() to get the size of an object from a pointer.

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

Editorial link. But its ok if you didn't intend for them to have avatars.

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

There is a style that I like to use. Note that { and } braces are ligned up on the same position and you normally do not put more than one statement on the same line -- there are some exceptions as you will see in the switch statement.

This kind of coding style makes it very easy to find mismatches { and } characters and other coding problems. I found at least two when I was reformatting your code.

int main()
{
    int a[4][13],d,i,j,m,num=0,t=0,b[52]={0};
    srand(time(NULL));
    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            a[i][j]=j+1;
        } 
    }
    for(;num<=52;)
    {
        d=rand()%52;
        for(m=0;m<num;m++)
        {
            if(d==b[m])
            {
                break;
            }
        }
        if(m==num)
        {
            b[num]=d;
            switch(d/13)
            {
                case 0:printf("红桃");break;
                case 1:printf("方块");break;
                case 2:printf("草花");break;
                case 3:printf("黑桃");break;
            }
            num++;
            b[t++]=a[d/13][d%13];
            printf("%2d%c",a[d/13][d%13],num%13==0 && num!=0?'\n':' '); 

        }

        paixu(0,13);
        paixu(13,26);
        paixu(26,39);
        paixu(39,52);
    }
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

see the functions in time.h, specifically localtime() or gmtime()

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

If the longest word is only 8 characters then you can put any nunber you want that is equal to or larger than 9. You don't have to specify a value that exactly matches the length of the largest character, a larger number is perfectly ok. The number needs to match the number of characters that RsvrdWrd can hold. Since you defined it as 12 then it should be ok.

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

This is what I suggested

char* DLL_EXPORT GetDirectory(char* returnbuf)
{
    char buf[255] = {0};
    ExpandEnvironmentStrings("%CommonProgramFiles%", buf, sizeof(buf));
    strcat(buf,"\\Adobe\\Adobe PCD\\pcd.db";

        //Write a function to get the installation directory.
    return returnbuf;
}

Now, in some applcation program

char buffer[255];
char* ptr = GetDirectory(buffer);

if( ptr == NULL)
{
   // error
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() doesn't work that way. The second parameter is the maximum number of characters to be read, including the null terminating character. The third parameter, if it exists, if the character that you want getline() to stop reading when it is found. That character is NOT added to the character array (RsvdWrd).

Are there any words in that file that are longer than 11 characters? If there is, then you will have to increase the size of RsvrdWrd array so that it can accommodate the largest word in the file.

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

If you don't want to be a member of DaniWeb then just simply stop posting. It isn't any easier than that.

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

it gives what error? Did you include <string> header file?

If RsvrdWord is an array of 12 characters why are you tring to read in 13 on your getline()?

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

That's ok Dani, not a big deal. When you get around to it would you also see why there are no avatars in that forum?

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

>>Choose one, will ya? :-)
You quoted me out of context. I said "we do" in response to your statement that you didn't think we could see those links.

I don't really have a problem with redirects when there were other posts in the thread. But leaving redirects to threads with no posts other than the original one is what I meant by cluttering up the list of threads.

Take a look at all the moved threads just in the first page of Community Feedback forum -- there are 10 of them that have redirects. I'll bet my next paycheck that there were not even one of them that contained more than the original post when it was moved.

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

how is sign and RsvrdWrd declared?

As for the extra character -- why don't you try reading the file into std::string object then copying the info to the RsvrdWrd.

void loadR()
{
ifstream file;
std::string line;
file.open("C:/CaseStudy/CaseStudy/Rsrvd.txt",ios::in);
for (i=0; i<44; i++) {
   getline(file, line);
   strcpy_s(sign[i].RsvrdWrd, 12, line.c_str());
//file.getline(sign[i].RsrvdWrd,13,'\n');
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ohhh! I want one of those :)

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

For watever good it will do you, it just this simple:

ofstream out("filename.txt");
out << address;
out.close();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you have to write an OnTimer() event handler. That is a function that you want MFC to call every second. This example has it in CMainFrame, but you can put it in any of the CWnd derived classes, such as CMyDialog. You can have up to 10 timer events active at the same time, so nIDEvent parameter just tells which event is being called. You set that event number when you start the timer, explained below.

void CMainFrame::OnTimer(UINT nIDEvent) 
{
   MessageBeep(0xFFFFFFFF);   // Beep
}

Next, you have to turn on the timer somewhere in the code.
m_nTimer = SetTimer(1, 2000, 0);

  • The first parameter is an id number that you want MFC to use to identify the timer event. The OnTimer() function will be passed that number (see above)
  • The second number is the number of milliseconds you want the timer event handler to be called. The example shows it wants the event to be fired every two seconds.
  • The last parameter is a pointer to the function you want to be called. If that parameter is 0 (or NULL) it is assumed to be the OnTimer() method of the MFC class in which SetTimer() is called. Otherwise, if the prameter is Not called then it can be any function you want. See the SetTimer link for a more detailed explaination.
  • The return value is the MFC id of the timer event, if SetTimer() is successful. Use this value to pass to KillTimer() to …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

GetSystemMatrics() works for the display monitor only. You have to call other win32 api functions to get the informatgion you want. To get the window's height/width call GetWindowRect()

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

>>I just want to edit the entry point of that exe
I'm not sure you can do that. The entry point is somewhere in the compiller's startup code that it attaches to the program during link time. We have no idea what that address is because the address is not resolved until the os loads the program into memory.

>>I also knew that the LoadLibraryA address never change for any application.

Whatever gave you that impression? The address returned by LoadLibrary() is the address within the calling process's address space which can change every time the process is loaded into memory. There is no guarentee that the address will remain constant from one run of the process to another.

Any attempts to hack that address could have serious consequences for the operating system and even possibly harm computer hardware.

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

Create a timer event -- see MSDN for SetTimer() and OnTimer() methods.