Re: How to get over this error?




mario.zoric@xxxxxxxxx wrote:

Hi to all!
I have one big problem. I have written some code and I want to program
at the end looks good but theres one uninspected error.
What's going on?
I have written code for programm that needs to do input, output and
searching, for looking better i wanted to use simple DOS word cls
but(!!!!) in C/C++ there i cant use it. so I looked over the internet
and nearest i could find it's this code:

void gotoxy(int, int); // prototype
void clrscr(); // prototype
int main(){

// write text in 4 corners of the screen

clrscr(); // function call
gotoxy(10,10); // function call
cout << "at 10,10";
gotoxy(10,20); // function call
cout << "at 10,20";
gotoxy(20,10); // function call
cout << "at 20,10";
gotoxy(20,20); // function call
cout << "at 20,20";
return 0;
}


// function definition -- requires windows.h
void gotoxy(int x, int y){

HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout.flush();
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}


// function definition -- requires process.h
void clrscr(){
system("cls");
}



I have compiled it in Microsoft Visual Studio 6.0 and there i had
error, it said :
c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal
error C1189: #error : "eh.h is only for C++!"

I looked for line where it is and that becomes that it's in standard
Microsoft Visual Studio 6.0 header file eh.h
line around the error are this:


#ifndef __cplusplus
#error "eh.h is only for C++!"
#endif


So my question is what i have to do to fix this error. I tried a lot of
combinations but I failed.

Thank You for help.

The code is C++, not C, and so you've posted to the wrong newsgroup.
Even if cout were defined in C (it isn't unless you've done it
yourself), you couldn't bitshift it by a string. The definition of
gotoxy() could theoretically work in standard C with appropriate
headers and libraries, but based on the identifiers and the comment
before it I'd say it was a nonstandard Windows console routine, and
therefore offtopic. The #error directive in eh.h is actually trying to
help you by letting you know that the code only works in C++ (I suspect
that if you took the code to a different operating system and compiled
it as C++, if you had the same headers, you'd get a different #error
directive telling you that the code only worked under a Windows system,
or something to that effect). The definition of clrscr() is strictly
portable but will behave in an implementation-defined manner if called
(although it might quite possibly work on the system you use), and the
comment at the start is misleading because system() requires stdlib.h,
not process.h. // comments don't survive line-wrapping and aren't valid
in C89, so posting them to comp.lang.c is generally unwise.

At this point, many regulars would set followups to comp.lang.c++, but
I don't think you'll have any luck there either.

I don't know what a 'word cl' is but it's worth thinking about whether
you need one at all, as it reduces the portability of your code. As so
many people use C in all sorts of different contexts and different
systems, there are many newsgroups available. comp.lang.c is only for C
programs or sections of C programs which are portable across all C
systems; if there was just one newsgroup for all C questions, it would
be much harder to find the relevant questions/experts. It is also not
for C++, and AFAIK comp.lang.c++ is only for standard portable C++, so
you'll have to find a new program to work from or a different newsgroup.

.



Relevant Pages

  • Re: OE6 newsgroup reader problem...
    ... every time you open the newsgroup, ... Now return to "Get XXX headers at a time" and uncheck the option completely; ... unless you copied them to another folder for archiving. ... at a time", that is, to download all the headers again. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Newsgroup problem
    ... Setting up Outlook Express Newsreader ... Remove Get XXX headers and click on this link and see if all messages download. ... To mark an individual message as read or unread, ... To mark all newsgroup messages as read when you quit Outlook Express or go to another newsgroup, on the Tools menu, click Options. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OE Is Deleting My NG Headers
    ... You can get situations where headers appear and when you go to get the ... remains until the newsgroup is next synchronised. ... Compacting was supposed to work in the ... I was playing aroudn with the synchronization settings, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OE Is Deleting My NG Headers
    ... newsgroup folders can easily be replaced. ... The delete option when compacting was also a common cause of file ... I don't have any problem getting headers. ... I was playing aroudn with the synchronization settings, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Manipulating with large numbers in C
    ... The reason for this newsgroup's focus on portability has been ... reputation, and by extension the reputation of your product, by ... and nobody has ever said it did. ... It is your attitude and your behavior in this newsgroup that is ...
    (comp.lang.c)