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

email_list[i] is not a pointer so it can't be tested for NULL (0x0 == NULL). Line 17 doesn't set a pointer to NULL, but instead sets the first byte of the last element to '\0'. There are still 256 bytes in that array. You would have been correct had it been declared like this char* email_list[LIST_LEN]

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

you need something like this:

for(i = 0; i < 3; i++)
{
   scanf("%s", names[i]);
   printf("You entered '%s'\n", names[i]);
}

But beware of scanf() because it will let you enter more characters than the buffer can hold. Try entering some text of 30 characters and see what happens. You can tell scanf() to limit the number of characters like this: "%20s" where the value 20 is the size of the buffer.

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

line 22: cknull macro is useless waste of cpu time becaye strcpy() will never return NULL unless a NULL pointer is sent to strcpy() as the destination string. If that happens strcpy() will just crash the whole program because it will attempt to write to memory address 0.

The value of filename is never set to anything but "".

Try changing that part like this: for(i=0;email_list[i]>0x0;i++).

That won't work. The original code is ok because it's checking for email_list[i][0], and that is the same thing as *email_list[i]

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

You failed to initialize and set the value of variable i. It just contains some random value. A for loop would be better than the while loop.

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

do you mean you want to list all members so that they are ordered by teamid? Or do you just want to select rows which have temaid = 2?

Do you know SQL? If not, then you need an SQL tutorial

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

Learn to program first.

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

Probably not. EVERYTHING in Windows 8 is diffeent than in previous versions. Either get used to it or reinstall Windows 7.

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

Then just change his code like this: (notice it should be 9 instead of 8)
char SOURCE[9] = "39 04 7d";

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

Sorry, I don't know the answer to that. Before you attempt to debug you have to make sure there were no compiler-reported errors. You should also resolve all the warnings that occur in the code you wrote (not the compiler's header files). The compiler will not generate the pdb file if there were errors in your program.

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

In many cases there are no equivalent header files. MS-Windows compilers do not normally support POSIX standartds or functions. However the MS-Windows port of GCC has ported many of the *nix POSIX functions to MinGW compiler.

If you want to find out what header file contains a specific function then google for "msdn function_name", replacing function_name with the name of the function you are interested in. Once you find the page on MSDN scroll down towards the bottom of the page and it will tell you the names of the required header files and library files.

This makes porting programs from *nix to MS-Windows difficult and time consuming.

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

The problem is fgets(). That function adds '\n' to the end of the string. So after calling fgets() you need to remove it.

char* ptr;
fgets(name_part1,10,stdin);
if( (ptr = strrchr(name_part1,'\n')) != NULL)
   *ptr = 0;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you probably need to put a space between the two parts so that they don't both run together. An easy way to do that is like this
sprintf(p->name,"%s %s", name_part1,name_part2);

You just need to make sure that p->name is long enough to hold both names plus a space.

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

Now my question is when im permitted to do this.is this a valid c command ???

Yes it is a nearly valid statement. You do that when you want to assign a single character to a specific location within the string
p->name[(p->count)++] = 'A';

or this
p->name[(p->count)++] = input_name[0];

what is p->count supposed to represent? The number of characters in p->name? If yes, then you don't need it, to get the length of name just call strlen().

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

if you want to use strcpy() just do this: strcpy(p->name,input_name);

gets(input_name);

Never call gets() because it will allow you to enter more characters then the buffer can hold. All excess characters are just scribbled all over your program's memory. Instead, call fgets() like this: fgets(input_name, sizeof(input_name), stdin); <<< stdin is the handle to keyhboard input. You can put any open file handle there but if you want input from keyboard then use stdin.

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

the declarations are in header files so all compilers will provide them just like they provide all other header files.

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

If you rebuild the program VS will re-generate the pdb file in the same folder as the *.exe file. The default folder is either Debug or Release. If there are any compiler errors the *.pdf will not be generated.

The only time it is needed or used is if you start a debugging session, oterwise you can delete it.

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

does the same 'iostream' file have codes for both windows and linux?

To us programmers they are all the same code, the operating system is transparent to the programmer. For example your program uses cout the same way on all operating systems, and that's because there is an international c++ standard. The c++ standards committee dictates to all compiler vendors what functions/classes have to be implemented, but do not say how the functions/classes are to be implemented. You can write cout << "Hello World\n the same way with all c++ compliant compilers. We are not normally concerned about how compiler makers implement standard c++ functions/classes , unless of course you write your own compiler or work for a company that make compilers.

you kind of missed this question
Yes, that was my answer to #4, not #3.

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

which file are you talking about?

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

we are not going to just hand you the code, but will be glad to help you with your program. What exactly don't you understand? Have you read your textbook about file handling? Have you used google to search for "fstream tutorials"? I suspect not.

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

a null pointer value means a pointer whose value is set to NULL, for example

char* somepointer = NULL;

You should set pointers to NULL when they don't point to something useful so that you can tell if the pointer has a valid address or not. If you allocate memory to the pointer using the new operator, then later delete it you need to set the pointer to NULL to insure you don't attempt to access the deleted memory again. Failing to do that is the cause of many bugs and hours/days of hunting down programming errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. because it's in the std namespace, as are all the other classes in the fstream and iostream header files.

  2. dont' know, but Mike probably does

  3. Yes, because they are implemented by different compilers. The same iostream is implemnentsed by all c++ compilers, that doesn't mean they are all implemented in the same way. All the underlying code is operating-system dependent. We as programmers just don't see it.

where can I find the real code of iostream

If you have a c++ compiler then you already have it, or most of it. Just read the header files, but be warned that the header files are nearly undreadable. Some of the source code is in libraries or DLLs or shared libraries, depending on the compiler. To see that you will have to spend a lot of $$$ to buy it from the compiler vendors, except for open source compilers such as gnu. In that event, just download all the gnu compiler's source code and read to your heart's desire.

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

to cure all illness

You'd also put everyone in the medical field out of work. No doctors, nurses, hospitals, hospital staff, ambulances, medics, medical insurance companies and all their employees, no government health agencies and all their employees. That means millions more people added to the provity lines and on public welfare.

to end all poverty

Well, if you end all illness then you can't possibly end poverty because you just put millions of people out of work.

end all bloodshed

Here again you're putting millions of people out of work. A large part of the world's economy is based on war and crime.

Be careful what you wish for because you might not get what you want :)

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

This is one of the few times C and C++ are different, at least in older versions of C. At one time NULL was defined as (void *)0 e.g.
#define NULL (void\*)0, so it was an error to assign NULL to a non-pointer. Turbo C still uses that since its such an old C compiler. Don't know if the newest C standards kept that or not.

And in segmented compilers such as Turbo C
in Large memory models #define NULL (_FAR void\*)0
in small memory models define NULL (_NEAR void\*)0

When 32-bit compilers and operating systems were invented, the compilers used flat memory models so the definition of NULL was changed to just (void*)0, no mention of memory model because programs were no longer segmented.

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

you have to tell the program what names you want to print. Here is one way to do it

printf("%s ", student.name[0]);
printf("%s ", student.name[1]);

or this
printf("%s %s ", student.name[0], student.name[1]);

And here is another way

int i;
for(i = 0; i < 2; i++)
   printf("%s\n", student.name[i]);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int main()
{
    college student ={"james",
                      "carter"};


    printf("%s %s ", student.name);
    getch();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would be in favor of a feature similar to "flag bad post" but for an edit request, for small edits like fixing formatting.

You mean we can't do that now??? Just hit Flag Bad Post and comment "add code tags" or some other editing problem.

I don't like the idea of non-mods editing posts -- too dangerous no matter how good the intent. As I said earlier, all members already have the ability to suggest mods edit posts for some reason.

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

after going through the file you have to reset the file stream back to the beginning of the file.

infile.feekp(0);

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

I gave you the code the read the file, you just chose to ignore it.

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

The entire thing works.

Not possible. Line 27 is wrong, as I explained in my last post. open() doesn't take a std::string as the first argument, it takes only char*.

and line 28 should be if( !infile.is_open()) instead of if( infile.fail())

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

line 2: how is variable file declared? If it is std::string, you can't do it that way.

file += ".txt" 
infile.open(file.c_str())

if file is declared as a character array do this:

strcat(file,".txt");
infile.open(file);

Your program doesn't need that for next loop. Just a while loop will do ok

while(true)
{
    cout << "Enter Student ID (999 to end): ";  
        cin >> searchId;
    if( searchId == 999 )
       break;
    while( inFile >> ID >> lastName >> firstName >> q1 >> q2 >> q3 >> q4 >> final )
    {
       // do something with the data
      if (searchId == ID)
      {
          avgGrd(q1, q2, q3, q4, final, average, grade);
          cout << "  " << left << setw(12) << lastName << "  " << setw(12) << firstName << ' ' 
             << setw(3) << average << ' ' << setw(2) << grade << endl;
          break;
      }
  }
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You probably can't get legal license for VS 2008 any more, get VS 2012 Express editiion is free for both personal and commercial use. But I suspect your hardware isn't large or fast enough.

Here is a link to VS 2008 hardware requirements. I think you can use your current hardware

Here is the hardware and os requirements for visual studio 2012

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

The nice thing is you get the turkey free :)

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

. I think it is not a good thing to learn. right

Wrong. You will never go wrong learning something.

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

win32 api is the MS-Windows operating system functions, all programs that run under MS-Windows call them. There are thousands of win32 api functions, so learning them all can take years. But the basic functions aren't all that complicated and can be learned in a few hours or days. The tutorial I posted is pretty good at teaching the basics. All you need is a good modern C or C++ compiler, and there are several free ones such as Code::Blocks and MS Visual Studio 2012.

Not many programs are written in pure win32 api functions any more because of higher-level compilers and languages such as C# and VB.NET.

Microsoft has developed a new layer to the os called .NET. I don't know if .NET eventually calls win32 api functions or not, I suspect some do and some don't.

You can never go wring learning the basics of how MS-Windows programs work even if you eventually program in one or more of the higher-level languages.

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

All that is doing is creating and displaying a blank window. Read the tutorial link I posted if you want to learn more about how to make dialog boxes, menues, and controls.

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

Doesn't really matter because the world is coming to an end in 13 days (21 Dec). :)

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

probably because you didn't write code to do it. Sorry, but a vague question deserves a vague answer.

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

Since you are new to win32 you should have read this tutorial

Use TextOut() for drawing text in a window. Here is a YouTube video that shows how to use it.

Here is a list of all the font and text functions that you can use

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

The const return value in that example is pointless and does nothing. The time to use const return value is when the method is returning a reference or pointer to one of it's data items, assuming you don't want the calling function to change the value.

class foo()
{
public:
   const int& foo(int index)
   {
      return items[index];
    }
private:
   vector<int> items;
}

Put const after the function name is a different matter, it means the function changes nothing. For example, the following is an error.

class foo
{
public:
    foo() {}

    bool bar() const
    {
        x = 1;  // <<<<< Error because function is const
        return true;
    }
private:
    int x;
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have it off too, and for the same reason. Nobody's business what I'm doing.

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

You can always turn on invisibility mode in your Profile then you won't appear in the activity stream.

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

You will have a lot easier time reading/writing the Movie structure if you replace the std::string with char arrays, something like below. std::string can not be easily written to binary files.

In c++ program I like to use a constructor to initialize the data rather than initializing the data in some other function or class. Structures are almost identical to class in c++.

struct Movie
{
    char sTitle[126];
    char sA1[80];
    char sA2[80];
    unsigned int sYear, sTime;
    Movie()
    {
       memset(sTitle,0,sizeof(sTitle));
       memset(sA1,0,sizeof(sA1));
       memset(sA2,0,sizeof(sA2));
       sYear = sTime = 0;
    }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You mean you want to work on your vacation? Take some time off from programming and do something else, like skiing, sky diving, or scuba diving. Or just relax, go to the beach and watch the girls go by.

mrnutty commented: They don't realize that these young days are very precious. Preach AD preach! +0
nitin1 commented: hahaha... awesome. i already have a girl friend. :p +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

write this program to find out how large the vector class is

#include <vector>
#include <iostream>

int main()
{
   std::cout << "sizeof(vector) = " << sizeof(std::vectgor)) << '\n'
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I found the solution by googling a bit more than I had before posting the question. I'm just learning vb.net too.

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

The vector will be slightly larger for the class's other data members. But the array of integers will be the same size. If you don't need the methods of a vector them use a normal array.

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

I figured it out. I had to create another Form then call it's ShowDialog() method. I renamed class Form2 to MyMsgBox, and run the code below

                    Dim box As New MyMsgBox()
                    box.lblText.Text = "Division by 0 error"
                    box.ShowDialog()
                    box.Dispose()
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ListBox.SetSelected -- click here

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

When my program calls MsgBox it appears in the middle of the monitor. Anyone know how to move it somewhere within the boundries of my program's window?

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

Please post the Horse and Track classes.