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

Why does result() have two parameters when only the first parameter is needed?

int result (int number)
{
    int number_rev = 0;
    while (number != 0)
    {
        number_rev = (number_rev * 10) + (number % 10); 
        number = number/10;
    }

    return number_rev;
}
ddnpresident commented: Thank you so much for the help, I don't know what I was thinking when I did the code initially +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is "argument"? It has to be a string literal, can not be the name of a variable. And did you include tchar.h? For edxample

#include <Windows.h>
#include <tchar.h>
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << _T("Hello World\n");
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

windows.h should be sufficient. There are a lot of other macros in tchar.h. My preference is to (almost) never use L because L is not portable between UNICODE and non-UNICODE programs, while the _T() and _TEXT() macros are. If you use _T() you can turn UNICODE on and off without changing the program.

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

You can't. Those are macros that work only on string literals -- text within quotes such as "Hello World". You have to call a conversion function to convert char* to wchar_t*. Study the link I gave you.

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

_T() is the same as _TEXT(), which converts a string literal to UNICODE, for example _TEXT("Hello World"); Those two macros do nothing for character arrays. These macros are translated at compile time as either wide characters (wchar_t*) or normal ascii characters (char *).

L is not a macro but forces the string literal to be wchar_t*, regardless of whether the program is compiled for UNICODE or not.

LPCWSTR is typedef for a pointer -- same as const wchar_t*, and LPCTSTR is typedef for const char*

Here is a more comprehensive tutorial

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

The line static int x = 10; is only executed during the first call to the function,

The value of static variables is set at compile time just like all other global variables.

In Main, the line fun() = 30; is the first call to the function and so x is brought into existence and set to 10.

No. See my previous comment.

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

The Expess version of Visual Studio is also free.

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

I love this free tutorial, see Chapter 13 for database

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

You can't put functions in header files -- move lines 18-21 into main.cpp or some other *.cpp file.

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

i don't like to much of 8, because it's like i need a touchscreen because of it's 'start menu')

Wrong, Windows 8 does not require touch screen. Anything you can do with touch screen you can do just as easily with the mouse.

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

No -- it's impossible to get that precision in operating systems such as MS-Windows and *nix. You need a real-time os such as MS-DOS 6.X in order to do that. I recall reading about some 3d party add-ons to turn MS-Windows into real-time os, but the cost a lot of money.

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

All you had to do is hit he Flag Bad Post link and report it to the moderators.

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

Spicy foods don't prevent cancer. My son has always loved spicy foods such as jalapeno, and now he has cancer. If anything, I would say spicy foods cause cancer.

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

How do you get that output from that input??? Your teacher must have given you some instructions on how to do it because the example you posted makes no sense.

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

Here's how to copy files from one computer to another on the same network. Software programs are another thing -- you should just install them on the new computer as mentioned previously by rubberman.

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

In my area there are places where women can get free birth control stuff. And for men, there is always the vasectomy.

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

GET A JOB was referring to the parents, not the newborn babies! I thought that would be inferred, but maybe not.

If people can't get jobs then do something else with the time instead of making babies. Too many unwed mothers who have nothing better to do then get pregnant.

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

So I guess you're willing to sell the US to China? I don't think so.

According to this research paper, the 1987 estimate was $175 Billion, or $360 Billion adjusted for inflation to 2013 dollars. So where did you get that $320 Trillion from? Most of the land owned by fed government isn't even usable, such as the mountains of Alaska.

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

Note sure myself, but here is one place to start

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

I am done but there I have mistakes

LOL :) That's like saying "I am done building the car but the engine is not in it yet"

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

why would you write a class eith unused, empty functions??? Just delete the functions.

You can't override a class method from outside a class. You have to do it inside another class that is a child of the base class

class base
{
public:
   virtual void create()
   {
      cout << "Hello from base\n";
    }
 };

 class child : public base
 {
 public:
   virtual void create()
   {
      cout << "Hello from child\n";
    }
 };

Now then, if you don't want base to implement the function then make it a pure virtual function, like this:

    class base
    {
    public:
       virtual void create() = 0; // pure virtual function
     };

In this case, you can not instantiate an instance of base. class base MUST be overriden with a child class.

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

Do you know how to connect and use a database that is on the same computer as the program you need to write? Once you get that going moving the database to a different computer is trivial. It's all in the connection string, just add the IP address of the compute on which the database is located.

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

wth are people still trying to use turbo C

Because many universities are too damned ignorant and lazy to upgrade their skills. And they have the nerve to call themselves institutions of higher learning!!

and oh, learn English

I don't have a problem with bad English grammer from people whose native language is something else. Last time I knew DaniWeb wasn't just for English majors.

ddanbe commented: Well said. +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Life is sometimes curel and inhumane, if you don't want to watch it then don't. Most of those Al-Qaeda animals could care less about human life. And least we forget, our countries have a lot of sickos as well.

Here is an article about recent cannabilism reports. A couple of songs have even been written about one of the cases.

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

The second parameter must be a web address, like in the examples in this article. Why would you want to use that function just to copy a file from one place to another on your own computer?

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

But where does that stop? Should authorities be able to shut down a web site just because some people find it objectionable? So far that hasn't stopped the proliferation of porn sites. It's a bit like free speech -- I may not like what you say but you have the right to say it.

I wouldn't read too much into what people say on those types of sites anyway. They all know they are anomonyous posters so they say almost anything that pops into their sick minds. Would they do it in real life? Changes are, no.

jwenting commented: well said +0
Mike Askew commented: Nailed it. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Like when u say "conio.h is not supported", so compiler doesn't support ? How can it be ?

conio is not a standard compiler header file. It was originally created by Borland in the 1980s for their Turbo C compiler. Read this wiki article to get more info about it.

The only header files that all C compilers must support are listed here. Anything not listed are non-standard and it's up to the compiler maker whether to support them or not. Almost all non-standard header files also require a library that contains the implementation of the functions in the header file. You generally can not use a library that was generated with one compiler with a different compiler. For example libraries generated with Borland compilers can not be used with Microsoft compilers for two reasons:

  1. The function naming convention is different
  2. Function calling convention is sometimes different.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

virtual void printf(); means you are going to implement the function in the *.cpp file instead of inlining in the class.

virtual void printf() {} is a do-nothing function, the function name exists but does nothing because there isn't anything betweein the two braces { and }.

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

You should remove virtual keyword for functions that are not inhereted from parent and from the function in parent that you do not intend to overload in derived class.

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

what compiler are you using? I get several errors from VC++ 2012, for example on line 59, can not initialize within class declaration. Check your compiler errors and fix them.

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

Created() function without nothing and can be changed outside of class

It can not be change by anything outside the class unless it is a child class of the class in which Created() is declared. Then it's called inheritence. For example you inherit certain traits from your parents, but you can not inherit traits from a neighbor who lives down the street (unless he/she is one of your parents). Same idea in c++ classes

class foo
{
public:
    virtual void Created();
};

class bar : public foo
{
public:
    virtual void Created();
};

int main()
{
     foo f;
     f.Created(); // calls Created in class bar
     f.foo::Created(); // call Created in class foo
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IMO you need to rethink how you are implementing this. You should have only one class that does serial port stuff, not two classes unless the two classes act as one class. One of the members of the class could be the serial port number so that the instance of that class can be assigned to a specific serial port. There are serial port cards that support anywhere from 4 to 64 (or more) serial ports on the same computer, and you wouldn't want to create a new class for each of them.

Second, you should have each instance of the serial port class in its own thread so that they can all work concurrently.

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

After you enter an integer you press the Enter key, right? Well, scanf() doesn't remove that key, so it remains in the keyboard buffer.

When you enter a number, scanf() will ignore white space until it reaches the first numeric digit then stop reading the keyboard when it reaches a character that is not a diget.

When you enter a string, scanf() reads all the characters in the keyboard buffer until it reaches the first white space character (space, tab, carriage return, linefeed). So if you previously called scanf() to enter a number, such as "%d" and then call scanf() again with "%s", the first thing scanf() finds is a white space, so it will do nothing.

C-language has no good standard way to clear everything from the keyboard buffer. The easiest way to remove the '\n' from the keybaord buffer is to call getchar() after each call to scanf() with "%d".

shahab.burki_1 commented: Thanks-- the getchar() worked +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no standard way of doing it, some compilers want quotes for your own headers, while other compilers will accept angle brackets. You need to read the documentation for the compiler you are using to find out how it want it.

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

wrong, no angle brackets < and > and put the filename in quotes.

#include "foo.h"

If you want to include a standard compiler header file then it's like this:

#include <stdio.h>

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

Here’s what the output from your program should look like

Links do not work.

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

Yes, but we won't do your homework for you. Make some attempt to do it yourself and post the program you wrote so that you can ask questions about what you don't understand.

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

Read your other thread -- I already told you how to do it.

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

You asked the wrong question at the beginning of this thread. Why didn't you say that in the first place, we can't read your mind. You need to use this function to launch Notepad.exe

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

In order to know if it worked or not you have to test the return value of fopen()

#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("c:\\1.txt","r+");
if( fp == NULL)
   printf("file not found\n");
else
   printf("Success!\n");
fclose(fp);   
return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

chalk it up to gremlins
65f91022ddc2dacdcf27de286c316186

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

MySQL is supported on many platforms (link)

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

Also disable the firewall during installation.

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

I've seen the same problem -- just happened today and lost some of the edits so I had to go back and edit again. I have to refresh the page after each edit -- which is a real pain in the ass.

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

I suppose it would be possible, but the compiler would probably be too huge to fit in memory. That's why compilers stick to just a single language. If you want more than one language, then write a compiler for each language, then write a wrapper program to call the appropriate compiler for the desired language. Microsoft Visual Studio is such a wrapper program and contains compilers for C, C++, C#, VB.NET and several other languages.

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

I have an Officejet 6500 on a home network that has Windows 7 Ultimate 64-bit, Windows 8, and a couple other Windows/Linux computers. I had no problems installing the device driver about a month ago. But I installed the HP Solution Center from here, not just the printer device driver.

Did you try to uninstall the existing priter device driver before installing a new one?

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

When calling a function you do not specify the data type of the parameters, just the names of the variables.

Line 26 should be: addition(n1,n2);

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

the values for INT_MIN and INT_MAX are shown in the appendices as being the same as SHRT_MIN and SHRT_MAX

It is compiler dependent. That was true 30 years ago when 16-bit MS-DOS compilers such as Turbo C were the standard at the time, but modern compilers are normally 32-bit or 64-bit and the ranges of variables are not the same. The C and C++ standards do not specify the ranges, only that char is 1 byte. The size of all others depend on the compiler, and how they implement the variables is usually dependent on the platform. That is all why you have to check limits.h to find the range for your compiler.

line 14: Why are you using EOF? That is the error code when End-Of-File is reached. It applies to file i/o and should not be used for any other reason. My compiler (Visual Studio 2012) defines EOF as -1. Yours apparently defines it differently.

it would stop within its range. Why is this not occuring?

It's called Integer Overflow -- and when that happens the behavior is undefined. On the compilers I used when the max value is reached the next increment will wrap back around to 0, but there is no guarentee that all compilers do that.

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

Curious: why didn't you use standard C string function strcpy() instead of your chop()?

lines 70 and 71: increase the size of those two because they probably aren't big enough.

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

Nice assignment.