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

@firstPerson -- he doesn't want to use an IDE.

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

>>how do I run my .cpp notepad files via the command prompt?
Depends on the compiler you install. There is lots of information about how to create make files for MinGW, which is the MS-Windows port of *nix g++ compiler. Or you can just compile it without a make file. c:> g++ world.c -o world.exe <Enter> The -o flag tells g++ what the final program executable name will be. On *nix they normally do not have extension, but on MS-Windows executable programs normally have *.exe extension.

You may need to set some path environmental variables before you run that command so that MS-Windows knows where g++ program is.

If you use a different compiler, such as vc++ 2010 express, the command line arguments will be completely different.

That's about as simple as I can make it.

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

One reason its named "Visual C++" because its a c++ compiler/IDE designed to make writing MS-Windows programs easier. Otherwise it will compile standard c++ programs without a problem unless you try to use something from the newest version of c++ standards which vc++ has not yet implemented. But then most c++ compilers are not 100% c++ standards compliant.

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

First you need to determine where the center of the tree will be, then set an int variable to be that value. The variable count is just the number of stars that will be printed on the current row.

int main()
{
    int center = 10;
    int count = 1;
    for(int i = 0; i < 10; i++)
    {
        printf("%*s", center, " ");
        for(int j = 0; j < count*2; j++)
            printf("*");
        printf("\n");
        --center;
        count++;
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Usually, you don't use it, use instead Return 0;

Unless, of course, exit() is used outside main().

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

The paramarater is the value that the program will return to the operating system so that other programs can use it for some purpose. The value 0 traditionally means the program exits normally without error. Any other value would mean the program encountered some kind of error. The value of the parameter to exit() can be anything you want, its not limited to the three that you posted.

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

Tutorials??? why -- yes there are.

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

you may also have to specify the open mode, e.g. filestr.open ("test.txt", fstream::in | fstream::out | fstream::app); With ios::app the file stream is set to end-of-file on each write operation. After the write its position is undefined, especially in text files. If you want to back up 10 characters then you may also have to take into account the line terminating sequence that your operating system uses. MS-Windows is two bytes, while *nix and MAC are one byte. Other operating systems may be something else.

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

Arch Linux / Firefox 3.6.3

I just finished installing Ubuntu 10 with FF 3.6.3 and do not see the problem shown in that screenshot. DaniWeb looks just like it does in Windows 7 and IE8.

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

why do those two functions have arguments? Did your instructor tell you to do that?

Move lines 4 and 5 down into main() before calling either of those two functions, delete lines 11 and 12, then you can use the same variables for both functions on lines 32 and 34. It's ok for main() to name the variables num1 and num2, and for the functions to name them something else.

Those two functions should return the results of the division or multiplication, and not return just 0.

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

why are the members of birthday char* instead of int? But to answer your question

node1->bday.month = malloc(32); // allocate space for 32 characters
strcpy(node1->bday.month,"January");

but if you mande them integers

node1->bday.month = 0; // January
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you meet all the requirements of "who can apply" then I'd think you would already know the material or what to study. If you are smart enough to get a bachelor's degree in Entineering then you will probably be smart enough to pass the test. But since I have not every taken it then I really have no idea.

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

Since you started this thread you should be able to mark it solved yourself.

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

That's because your compiler is ancient and uses obsolete header files. It's unfortunate you and your peers are forced to use such antiquated compilers.

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

That may be compiler implementation dependent. On VC++ 2010 Express fstream only includes istream. If you want cout then your program must include <ifstream>

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

1. You must be compiling that program as c++, not C because C requires the keyword struct before each use of the structure name, such as struct mystrut . Change the file extension of the program file to *.c

2. >>(first+1)->number
You can't access members like that because its a linked list, not an array. The correct way is first->next->number Its a lot simpler to use a loop

struct mystruct* node = first;
while( node )
{
   printf("%s\n",node->name);
   node = node->next;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'll bet the file is including windows.h ???? One of the errors references a function Sleep() that is in that header file. Remove all the include files from that *.cpp file.

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

Yes, you could, but be prepared to enter something if the keyboard buffer is empty.

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

scanf() leaves the Enter key '\n' in the keyboard buffer, so the next time scanf() is called it will only see '\n'. One solution is to replace scanf() with fgets() which will remove '\n' if there is room in the input buffer.

Something like this:

int main()
{
   char answer[255];
   fgets(answer, sizeof(answer), stdin);
   if( answer[0] == 'y' )
   {
       // blabla
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiler are you using? Generally it is not a good idea to mix C and C++ code together in the same program.

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

Start a new project that only contains main(). The errors you posted appear as if there are other *.cpp files in the project.

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

>>Umm... can you export your settings and send them to me so I can import them?

AFAIK that is not possible. You might want to post your question at Microsoft's forum

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

How long has that been happening? Just recently or a very long time? Did you install something that may have affected the compiler's installation? Try reinstalling Visual Studio, uninstall it completely first so that it will reinstall fresh.

Does kernel32.lib actually exist on the computer?

[edit]Oh, I reread your post and see you may have already tried that. Do you also have the Platform SDK installed? If you do then remove it then reinstall it.

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

Why is line 80 inside that if block? What good does it do? Line 80 declares an array of pointers which immediately goes out of scope and is destroyed.

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

Here you go

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

>>Wow are you serious?

Absolutely dead searious. The problem does really exist. :@

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

Microsoft decided to hide that menu on you thinking that programmers are too dumb to know how to use it. To activate the Build menu click on Tools --> Settings then select Expert.

jonsca commented: Good one, I hadn't stumbled onto that yet +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One more hint: you will need to know 4th grade math (add, subtract, multiply, and divide). What firstperson posted (except for the mod operator) was nothing more than what a 4th grader would learn in most USA schools.

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

Use mod % and division / operators. Since this is homework, sorry but I'm not going to say anything more about it until you post the code you have tried.

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

Those are debug version of the libraries. Recompile your program for release version and it may work on other computers. computers.

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

The memory is not really lost "forever" -- most operating systems reclaim the memory when the program itself exits either normally or abnormally (crashes). When using current versions of MS-Windows or *nix it is not necessary to reboot the computer.

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

It would be helpful if you posted the code you wrote.

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

If you are running MS-Windows I suppose you could call GetSystemTime() and use milliseconds as the seed value.

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

Post your code here instead of posting a link on some other computer -- which would not respond when I tried to read it. Just simply copy and paste the code in your post and surround it with [code] ... [/code] code tags.

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

You are using time() as the seed to srand(). Call srand() only once during the lifetime of the program, not every time you call rand(). Put the call to srand() near the beginning of main() and you will see different results every time rand() is called.

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

What makes you believe that rand() only produces one random value per second? Have you profiled it? What is the speed of your computer? A computer with a faster CPU will process code faster. I wrote a little program that generated 1,000,000 randm numbers on 43 millisonds and if I add the mod operator like you posted it generates them in 62 milliseconds.

If you are looking to speed up a program then look elsewhere.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main()
{
    time_t t1, t2;
    srand((unsigned int)time(0));
    t1 = clock();
    for(size_t i = 0; i < 1000000; i++)
        rand();
    t2 = clock();
    printf("time %u\n", t2 - t1 );

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

As we said before you could use any of the STL containers.

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

There are lots of ways to do it -- which one you use will depend on the data you want. std::string is a c++ class that manages chracter arrays and expands/contracts it on demand. vector, list, set, and map manage arrays or lists of objects, and also expand/contract on demand. Fially you could roll your own for any of the previously mentioned, but that involves a lot of work on your part and is very error-bug prone, which is the reason they are in the c++ language.

[edit]^^ Sorry Edward I didn't see your post.[/edit]

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

use global variables. You will have to synchronize access to the variables so that one thread doesn't try to read it while another thread is writing to it.

If you are writing a MS-Windows GUI program then you might be able to call SendThreadMessage().

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

call win32 api function SetFocus()

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

you have the val declared twice -- once on line 1 and again on line 3. You can not use the same variable name twice like that.

line 4: you have to call strcpy() to do it: strcpy(var[0],"ANS"); The = assignment operator will not work on character arrays.

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

>>AD- sort( ) can be called with just the start and end iterators, I assume it makes use of the < operator if no comparison function is provided.

Isn't that what I just said??? But it only works on POD and std::string. most everything else will require the third parameter.

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

There is a third parameter to std::sort() which is the name of a comparison function that you will write. That is not necessary if you have a vector of standard data types, such as int, double and std::string. Anything more complex such as a c++ class that you created will require the comparison function. See the example program at this link.

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

You can combine lines 10, 11 and 12 to use just one fseek() fseek(source, -10, SEEK_END); That will set the pointer 10 bytes from the end of the file.

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

redeclare values as unsigned char instead of int. Then your program will most likely display the data the same as your hex editor did.

You did not post the code you tried to get the last 100 bytes.

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

why are you using character arrays instead of integers?

why are you using C's gets() function instead of c++ cin?

If you really really want to use character arrays then you need to make them larger -- you have to account for the string's NULL terminating character. With integers you don't have to worry about that.

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

use getline() instead of >> operator and it will work

int main()
{

    string serial = "0";

    while(serial != "")
    {
        cout << "Please enter serial number:" << endl;
    
        getline(cin,serial);
        
    }
    cout << "All done\n";
}

[edit]Oops! didn't see Nathan's reply [/edit]

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

Its in the Software Development menu -- at the bottom.

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

Apparently Dani agreed with the OP:

Mobile Dev forum

Have fun.

Well then I think she needs to add a new forum for MS-Windows like I asked (and was rejected/ignored) over two years ago. There are hundreds of posts in the C and C++ forum that ask questions about win32 api.

jonsca commented: I'm for that! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to add the main() function that includes all the code that does the things you stated in your questions.

Will I write it for you? NO. You will learn nothing if I do that.