|
I've written an app i pure C yes. I discovered that the declarations of varibles couldn't be done anywhere in the code and has to be declared in the beginning of the scope. I've read in my "C: The Complete Reference" that C99 supports declarations anywhere in the code.
http://duden.mine.nu/wr/Client/
That's the project I've made.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Well, I have just read your project. I have a question reguarding to
that. In C++, it support OOP, so it is logically right to split files.
Header being class definition, and cpp being implementation and
driver.
However, C does not do OOP, so how do they split files? What do they
put in header file? Is it common to put everyting in a .c file? Well,
you did that for your WZ project.
P.S. I'm learning C++, but completely new to pure C.
Thanks
|
|
|
|
|
Yeah I did put everything in one .c file because it was just a test project and it had only a few hundreds lines of code. But yes, you do the same as in C++, put all your function declarations in one header file and globals and #defines and whatever you want and then implement it in your source file (.c or cpp).
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
At the moment, very few compilers support C99 - it's too new.
I believe that Microsoft is not intending to ever support C99 - they will only support C89 (as revised in 1995).
C99 adds a few features that frankly are only of use in building larger scale programs, and for that, there's C++.
IIRC, VC.NET (the environment) adds the /TP switch to your project settings, meaning that all files are compiled as C++ even if they have a .c extension. Turn this switch off if you want .c files compiled as C.
|
|
|
|
|
No, Visual C++ .NET 2002 does NOT support ISO/IEIC 9899:1999 C Language.
In MSDN of Visual Studio .NET 2002:
"Because the timing of the release of C99, this version of Visual C++ is not conformant with that standard."
You may try this sample code, which is of C99 code:
#include <stdio.h>
void main()
{
int v[10] = {v[0] = 3, v[5] = 5 };
int i;
for(i = 0; i < 10; i++)
{
printf("[%d +1] = %d \n", i, v[i]);
}
}
The result is wrong.
BuggyMax
|
|
|
|
|
Hi...
I'm not sure why the error - 'OnSelchangeLUCOMPTop' : local function definitions are illegal, comes out...how shd i ammend this...thanks.
void CComp::OnSelchangeLUCOMPTop()
{
UpdateData(TRUE);
Tselection1 = "Selection Changed";
CMain::uc_top = m_uc_ts.GetCurSel();
m_uc_epo.EnableWindow(TRUE);
m_uc_epp.EnableWindow(TRUE);
}
|
|
|
|
|
fynox wrote:
CMain::uc_top
That's illegal. I assume you somewhere have declared a pointer to the CMain class in your CComp class: CMain *pParent . For example declare in your header file: CMain *pParent and initialize it from your main class: CComp dlg; dlg.pParent = this; .
Then use this: pParent->uc_top = m_uc_ts.GetCurSel(); .
Hope that helps
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Sounds like you have failed to add a closing brace for a function preceeding this one in the same file.
void CComp::SomeFunction()
{
void CComp::OnSelchangeLUCOMPTop()
{
UpdateData(TRUE);
Tselection1 = "Selection Changed";
CMain::uc_top = m_uc_ts.GetCurSel();
m_uc_epo.EnableWindow(TRUE);
m_uc_epp.EnableWindow(TRUE);
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi there,
i have created a bitmap image and when i click on maximize or minimize button on the window it vanishes . what to be done for it . plz check it out and give the reply as early as possible .
Sreeram
|
|
|
|
|
Are you BitBlt the bitmap to the window DC? Probably you do so, and when you do so it will disappear when you repaint the client area which happen when you resize the window.
You'll need to paint the bitmap in your WM_PAINT handler.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Guys,
I've a dialog based application which is a very large size application and i am working on it for about 8 months.
For the last two days i am having a trouble. The problem is that on my machine i compile it using Visual C++ 6.0 compiler and when i run the debug version, it runs normally.
Now if i take the debug exe to other machine and run it, i get the following system error:
The instruction at 0x00000000 referenced memory at 0x00000000. the memory could not be read.
Strange if i compile the program on second machine and run it, it works normally. But if i transfer the same exe to first machine, i get the same error.
For some testing i compile program on first machine and try to run the application in debugger of second machine. I placed a break point in the InitInstance() of Application class. But it is crashing before the control enters the InitInstance(). Can anyone tell me how to solve the problem.
Oh yes one more thing. In my workspace there are five projects. Four of them are statically linked with MFC and use Debug Multithreaded dll confguration. While one is not using MFC. I am just using debug builds.
|
|
|
|
|
Hi,
This crash is happening because of different versions of MFC runtime libraries u r using in debug mode. U can find this by using dependency walker.
To resolve the problem u r facing
1. Create setup which will port all dependencies of ur application to other machine.(not a good option)
2. As u have mentioned, Four of them are statically linked with MFC and use Debug Multithreaded dll confguration, use "debug Multithreaded" option.
This will solve ur problem.
The chosen One
|
|
|
|
|
Hi all,
I want to draw sound wave but I don't know how to get the sound data. For example, I have a sound which length is 100 frames and I want to get the sound data at each frame.
Thanks in advance,
Dang Xuan Ky
|
|
|
|
|
Hi everyone
I want to ask u how to move character on the screen in vc++. And also (speech)voice in vc++ AS like MSoffice assistant(Help).
If there is any answer,pl let me know.
Thanks
|
|
|
|
|
Could someone pleae explain the following typedef?
I know that I_TextOutput is an abstract interface and
that GETPLUGIN is a function that will be loaded from a dll.
typedef void (*GETPLUGIN)(I_TextOuput**);
Thanks,
Steve
|
|
|
|
|
|
Ok, I follow that much. But take for instance this typedef
typedef float balance;
Here your are telling the compiler that balance is another name for float.
But in the case of the above mentioned typedef
typedef void (*GETPLUGIN)(I_TextOutput**);
Is void being defined as (*GETPLUGIN)(I_TextOutput**)?
What I don't understand is the makeup of the typedef itself.
Thanks,
Steve
|
|
|
|
|
|
Okay that makes more sense. As you said it is bizarre.
Thanks,
Steve
|
|
|
|
|
I'm using the old style of c++(console) and would like to know if there are some ingenius people out there and would like to find out how can a game of tic-tac-toe be artificially intelligent. How would I make the computer check anything. Please do help! little person.
#include <iostream>
using namespace std;
char array [3] [3]; //Tic Tac Toe array
char check();
void init_array();
void get_player_move();
void get_computer_move();
void disp_array();
int main()
{
char done = ' ';
init_array();
do{
disp_array();
get_player_move();
done = check(); //See if any winner
if(done != ' ') break; //Winner!!!
get_computer_move();
done = check(); //See if any winner again
system("cls");
} while(done == ' ');
disp_array(); //Display final array
if(done=='X')
cout << "You won!\n";
cout << "Programmed by:\n Tom Dziedzic \n";
if(done=='O')
cout << "I won!\n";
cout << "Programmed by:\n Tom Dziedzic \n";
return 0;
}
//Initialize the array
void init_array()
{
int i, j;
for(i=0; i<3; i++)
for(j=0; j<3; j++) array[i][j] = ' ';
}
//Get the player's move
void get_player_move()
{
int x, y;
cout << "Enter X,Y coordinates for your move: ";
cin >> x;
cin >> y;
x--; y--;
if(array[x][y]!= ' '){
cout << "Invalid move, try again.\n";
get_player_move();
}
else array[x][y] = 'X';
}
//Get a move from the computer
void get_computer_move()
{
if(array[1][1] == ' ')
{
array[1][1] = 'O';
goto e;
}
else if((array[0][0] == ' ' || array[0][0] == 'O') && (array[0][1] == ' ' || array[0][1] == 'O') && (array[0][2] == ' ' || array[0][2] == 'O'))
{
array[0][2] = 'O';
goto e;
}
e: ;
}
//Display the array
void disp_array()
{
int t;
for(t=0; t<3; t++) {
cout << array[t][0] << " | " << array[t][1] << " | " << array[t][2];
if(t != 2)
cout << "\n---|---|---\n";
}
cout << "\n";
}
//See if any winner
char check()
{
int i;
for(i=0; i<3; i++) /* check rows */
if(array[i][0]==array[i][1] && array[i][0]==array[i][2])
return array[i][0];
for(i=0; i<3; i++) /* check columns */
if(array[0][i]==array[1][i] && array[0][i]==array[2][i])
return array[0][i];
//Test diagonals for winner
if(array[0][0]==array[1][1] && array[1][1]==array[2][2])
return array[0][0];
if(array[0][2]==array[1][1] && array[1][1]==array[2][0])
return array[0][2];
return ' ';
}
|
|
|
|
|
|
thankyou
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
I'm assuming that what you want is the computer to play tic tac toe against a human, with the human being the x's. I'm not into A.I, but you can do this by brute force, since it's only tic tac toe with so many possible combinations. There are eight ways that the computer can win, and 8 ways that a human can win, for a total of sixteen winning combinations (3 vertical rows, 3 horizontal rows, and the two diagnols for each of the players). When it is the computer's turn, check all of the combinations for a win. If there is not immediate win, then check all of the human's combinations for a win and block it. Your check() function would have to be modified. What I would do, say for checking the computer for a win, is count the number of o's per combination, with the only possible counts being 0, 1, or 2. Save the combinations that don't have x's. This will be used for the computer's move, once it's determined that the human doesn't have a pending win forcing the computer to block. Now check all the combinations again, this time for x's to see if the human has a pending win that the computer must block. If there were 2 x's in a combination with a blank, then the computer would have to put an o in the blank to block the human's win. If the player didn't have a pending win, then go back to the saved combinations for the computer and programatically determine the best move, based on the counts in the combinations of o's. This is brute force, but with careful maniupulation, this would get the computer playing a human.
Ed
|
|
|
|
|
Thank you
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
I have a dialog based application - the dialog being a derivitave of CDialog.
The dialog does not have a title bar. I can customize the icon shown in the taskbar when I run the application, but I have no idea how to change the text on the taskbar.
When I enable the title bar, the taskbar shows the text that I enter in the caption field in properties. When I disable the title bar, and delete the caption, the text of course disappears from the taskbar. If I enable it, enter text in the caption, and disable it, my dialog acts pretty funky and the taskbar text does not appear.
|
|
|
|