i am not using any server or .. it plain winxp and plain turbo c editor have made a game using graphics and ofcourse keyboard i want to have mouse interface too ?help?
C language help regarding Mouse pointer?
well.. how to make the mouse pointer appear on a project in c??
i have the coding writen in a book which makes the mouse pointer appear in the program also reads if the mouse bottom is clicked or not but i just can seem to understand the terms used in making the program i searched the net but cannot find a specific article related to implement or initializemouse in c with clear deiscription ?? any particular sites would be helpful or a detail explanation thanku?
C language help regarding Mouse pointer?
Bestever resource is
http://www.programmersheavan.com
Cheers:)
Reply:C language? So let me get this, you created a game using the graphics api? Why not use opengl/direct3d or whatever. Is your game fullscreen?
Thursday, July 9, 2009
C language help?
Our instructor asked us to create this using C language(While Loop):
*
**
***
****
*****
and the reverse of that.
I can't install turbo C right now so I can't test if what I thought is right:
int i;
while(i=1; i%26lt;=5; i++)
printf("%d \n", i);
printf("*");
-Am I correct? Can somebody please explain?
C language help?
Okay, very good first try you are getting there. Let's re-read that code you wrote.
int i; /one variable
while(1 , 5, ++) / looping from 1 to 5 once
printf("%d \n", i); / error!!
Plus this first printf does not make that much sense actually.
Your output if it worked would be:
1
*2
*3
*4
*5
*
Which is not gonna get you a very good grade I think.
You need to just sit back and think about the problem without any C code.
Step one: What is the computer doing?
Answer: Printing * a different number of times 5 times.
So what does this mean? It means we need to have two variables. Let us give the variables real names as well, not just i. Let's call them line and asterisk.
So what do we need to do for the first line? Print one star.
Then print 2 stars. and so on.
Final version would look something like this:
int line, asterisk;
while (line=1; line%26lt;=5; line++) {
while (asterisk=1; asterisk %26lt;= line; asterisk++) {
FOR YOU TO DECIDE
}
}
Okay, so that is the basic control structure that you will be using, now you just need to get C up and running, and decide what goes in the "FOR YOU TO DECIDE" spot. Didn't want to do your homework for ya.
Also, if you need it Eclipse might be the IDE you want.
http://www.eclipse.org/
Reply:You're way off.
Your got the "for" loop syntax muddled with the "while" loop syntax. What you've written above will not compile.
replace the 'while' label with a 'for'. After that you will still not get what your instructor is looking for. You will simply be printing out a number and the * in the next line for each number. Get rid of the print for variable i and bring in a while loop. Initialize another variable and compare against the value for i and print a * till the new variable = i (since it will be incremented in each loop)
Heres the pseudo code
init two variables: i and j
for ( i=1; i%26lt;=5; ++i)
set j = i
for ( j = 0; j != i ; ++j)
print your *
print statement for an empty line with just a "\n" so that the next set of *s print in the next line as required by your instructor.
Dont want to write more than that.
Reply:Something like this might work:
for (int i=0; i%26lt;=5; i++){
for (int a=0; a%26lt;i; a++)
printf("*");
printf("\n");
}
Reply:there are a ton of ways to do this here's one
#include %26lt;stdio.h%26gt;
main()
{
int i= 0;
while (i %26lt; 5)
{
int j = 0;
while( j %26lt;= i)
{
printf("*");
j++;
}
printf("\n");
i++;
}
}
*
**
***
****
*****
and the reverse of that.
I can't install turbo C right now so I can't test if what I thought is right:
int i;
while(i=1; i%26lt;=5; i++)
printf("%d \n", i);
printf("*");
-Am I correct? Can somebody please explain?
C language help?
Okay, very good first try you are getting there. Let's re-read that code you wrote.
int i; /one variable
while(1 , 5, ++) / looping from 1 to 5 once
printf("%d \n", i); / error!!
Plus this first printf does not make that much sense actually.
Your output if it worked would be:
1
*2
*3
*4
*5
*
Which is not gonna get you a very good grade I think.
You need to just sit back and think about the problem without any C code.
Step one: What is the computer doing?
Answer: Printing * a different number of times 5 times.
So what does this mean? It means we need to have two variables. Let us give the variables real names as well, not just i. Let's call them line and asterisk.
So what do we need to do for the first line? Print one star.
Then print 2 stars. and so on.
Final version would look something like this:
int line, asterisk;
while (line=1; line%26lt;=5; line++) {
while (asterisk=1; asterisk %26lt;= line; asterisk++) {
FOR YOU TO DECIDE
}
}
Okay, so that is the basic control structure that you will be using, now you just need to get C up and running, and decide what goes in the "FOR YOU TO DECIDE" spot. Didn't want to do your homework for ya.
Also, if you need it Eclipse might be the IDE you want.
http://www.eclipse.org/
Reply:You're way off.
Your got the "for" loop syntax muddled with the "while" loop syntax. What you've written above will not compile.
replace the 'while' label with a 'for'. After that you will still not get what your instructor is looking for. You will simply be printing out a number and the * in the next line for each number. Get rid of the print for variable i and bring in a while loop. Initialize another variable and compare against the value for i and print a * till the new variable = i (since it will be incremented in each loop)
Heres the pseudo code
init two variables: i and j
for ( i=1; i%26lt;=5; ++i)
set j = i
for ( j = 0; j != i ; ++j)
print your *
print statement for an empty line with just a "\n" so that the next set of *s print in the next line as required by your instructor.
Dont want to write more than that.
Reply:Something like this might work:
for (int i=0; i%26lt;=5; i++){
for (int a=0; a%26lt;i; a++)
printf("*");
printf("\n");
}
Reply:there are a ton of ways to do this here's one
#include %26lt;stdio.h%26gt;
main()
{
int i= 0;
while (i %26lt; 5)
{
int j = 0;
while( j %26lt;= i)
{
printf("*");
j++;
}
printf("\n");
i++;
}
}
C language experts.......plzz help..?
i want to create "tic tac toe" game in c language.....with mouse programming
now could anyone plzz help me......how shud i begin....plzz give me a logic.........
problem is dat in a "tic tac toe" game without mouse......i can simply ask user to enter row and column of the matirx....and hence can be easily done..
now with mouse programing...the main problem is how implement the co-ordinate of mouse.......to a matrix..
as i dont kwn grphics in c...i just want to make a basic simple game with two user.....
so plzz tell me how to take input via mouse and set a value in matrix,clicked by player.....plzz dont include graphic in it.....as it would become difficult for me to understand
C language experts.......plzz help..?
Typically you would use a framework of some sort. Which framework is dependent on your development tools and platform. I don't believe your question is for C language experts (which I am not), but rather for C programmers who have experience with mouse inputs.
I think it would be helpful to know what C complier / libraries you are using and on which platform (OS) you are targeting before you will get any helpful advice.
Reply:You don't say which system you use (Linux, Windows,...) so I will give you generalities:
You will need to have an event loop that receives the mouse events and then perform some operation when the mouse event occurs.
And then map the mouse coordinates to your TIC TAC TOE grid. Example: suppose the "client" part (i.e. the part where you draw) of you window is 300 pixels / 300 pixels, you Will get the correct Tic Tac Toe grid coordinate by using mouse.X/100 and mouse.Y/100
But don't try to do this without a tool giving you support for GUI programing (Personally I use VISUAL C++ Studio express which is freely downloadable from Microsoft)
Reply:well I don't know how you plan on creating a tic tac toe game using a mouse if you don't plan on using a graphics library of some kind. I would recommend SDL as a good graphic library to learn and use if you change your mind on the graphics part. but as far as logic for the game an easy way to see if a square is clicked on would be using offset from where the user click from origin. The origin in computer programs is the top left corner of the program window so when the mouse is clicked the position can be gotten from the a function call which varies on the API your using. But you get the mouse coordinates and you see if they fall on your grid of 9 squares. so if the user clicks at (1,2) and your first box is at x = 3 y = 3 then if 1 your users x is less than 3 then boxes x and 2 the users y is less that 3 the boxes y then the user clicked in the first box and just repeat this offset for all the boxes
now could anyone plzz help me......how shud i begin....plzz give me a logic.........
problem is dat in a "tic tac toe" game without mouse......i can simply ask user to enter row and column of the matirx....and hence can be easily done..
now with mouse programing...the main problem is how implement the co-ordinate of mouse.......to a matrix..
as i dont kwn grphics in c...i just want to make a basic simple game with two user.....
so plzz tell me how to take input via mouse and set a value in matrix,clicked by player.....plzz dont include graphic in it.....as it would become difficult for me to understand
C language experts.......plzz help..?
Typically you would use a framework of some sort. Which framework is dependent on your development tools and platform. I don't believe your question is for C language experts (which I am not), but rather for C programmers who have experience with mouse inputs.
I think it would be helpful to know what C complier / libraries you are using and on which platform (OS) you are targeting before you will get any helpful advice.
Reply:You don't say which system you use (Linux, Windows,...) so I will give you generalities:
You will need to have an event loop that receives the mouse events and then perform some operation when the mouse event occurs.
And then map the mouse coordinates to your TIC TAC TOE grid. Example: suppose the "client" part (i.e. the part where you draw) of you window is 300 pixels / 300 pixels, you Will get the correct Tic Tac Toe grid coordinate by using mouse.X/100 and mouse.Y/100
But don't try to do this without a tool giving you support for GUI programing (Personally I use VISUAL C++ Studio express which is freely downloadable from Microsoft)
Reply:well I don't know how you plan on creating a tic tac toe game using a mouse if you don't plan on using a graphics library of some kind. I would recommend SDL as a good graphic library to learn and use if you change your mind on the graphics part. but as far as logic for the game an easy way to see if a square is clicked on would be using offset from where the user click from origin. The origin in computer programs is the top left corner of the program window so when the mouse is clicked the position can be gotten from the a function call which varies on the API your using. But you get the mouse coordinates and you see if they fall on your grid of 9 squares. so if the user clicks at (1,2) and your first box is at x = 3 y = 3 then if 1 your users x is less than 3 then boxes x and 2 the users y is less that 3 the boxes y then the user clicked in the first box and just repeat this offset for all the boxes
How to learn C Language?
Hi everybody,
I want to learn C Language and want to be expert in this language. But I am very confused that from where I should start to learn it. I have visual studio 6.0 installed on my pc that have Visual C++.
But when I open this application, I cann't understand what to do and how to do.
Can anybody help me please? And tell me also which Version of 'C' I should use and from where I should start to learn this language.
Pl. reply asap.
Thanx.
How to learn C Language?
Try learning from a book. It is best taught by a teacher. I am studying at calTech and i have never used C. C is a very old language. Try learning JAVA which is just an improvement over C
Reply:Borland C++ is a good program, but u should take a class called computer science to learn the c++ language, cos I am taking that right now.
Reply:well, i recommend Dev C++ and read this site :http://www.cplusplus.com/
http://actualtecnologia.blogspot.com
Reply:i compleated my diploma in computer applications,i don't know how to start and learn "c" language
Reply:please i suggest you one that u must learn by teacher to gain more knowledge about c.
Reply:Not much help with this stuff but im going to have to say i agree with what everyone said an responded to!!
Reply:First you should have TC (Turbo C - MS DOS program) to start with...At the moment forget about Visual studio...
Try the book 'Programming in ANSI C - E Balagurusamy'....for beginning
If you completely understand almost the concepts of this book, then go further trying more complex programs, you will decide what you should read for more understanding....
If you want to be expert in C, then take your time...and first clear this book....Have a nice journey in C... :-)
bouquet
I want to learn C Language and want to be expert in this language. But I am very confused that from where I should start to learn it. I have visual studio 6.0 installed on my pc that have Visual C++.
But when I open this application, I cann't understand what to do and how to do.
Can anybody help me please? And tell me also which Version of 'C' I should use and from where I should start to learn this language.
Pl. reply asap.
Thanx.
How to learn C Language?
Try learning from a book. It is best taught by a teacher. I am studying at calTech and i have never used C. C is a very old language. Try learning JAVA which is just an improvement over C
Reply:Borland C++ is a good program, but u should take a class called computer science to learn the c++ language, cos I am taking that right now.
Reply:well, i recommend Dev C++ and read this site :http://www.cplusplus.com/
http://actualtecnologia.blogspot.com
Reply:i compleated my diploma in computer applications,i don't know how to start and learn "c" language
Reply:please i suggest you one that u must learn by teacher to gain more knowledge about c.
Reply:Not much help with this stuff but im going to have to say i agree with what everyone said an responded to!!
Reply:First you should have TC (Turbo C - MS DOS program) to start with...At the moment forget about Visual studio...
Try the book 'Programming in ANSI C - E Balagurusamy'....for beginning
If you completely understand almost the concepts of this book, then go further trying more complex programs, you will decide what you should read for more understanding....
If you want to be expert in C, then take your time...and first clear this book....Have a nice journey in C... :-)
bouquet
C language Installation Setups and Installation Guidelines?
from where should i get the installations for C language programs?. How can i install the setup and work with it.
I need the settings of options in C language too. Pls help me.
C language Installation Setups and Installation Guidelines?
Try getting a book on it from here
http://freecomputerbooks.com/
I need the settings of options in C language too. Pls help me.
C language Installation Setups and Installation Guidelines?
Try getting a book on it from here
http://freecomputerbooks.com/
C language Installation Setups and Installation Guidelines?
from where should i get the installations for C language programs?. How can i install the setup and work with it.
I need the settings of options in C language too. Pls help me.
C language Installation Setups and Installation Guidelines?
Can you be specific, If you wan to write and modify C programs and don't know where to start, get a c/c++ compiler. go to www.thefreecountry.com for free compilers, usually Bloodshed Dev-c++ and borland c++ are good. Look up tutorials on c/c++ www.cprogramming.com, www.programmingtutorials.com
I need the settings of options in C language too. Pls help me.
C language Installation Setups and Installation Guidelines?
Can you be specific, If you wan to write and modify C programs and don't know where to start, get a c/c++ compiler. go to www.thefreecountry.com for free compilers, usually Bloodshed Dev-c++ and borland c++ are good. Look up tutorials on c/c++ www.cprogramming.com, www.programmingtutorials.com
Is C language programs use to make operating system?
If C language programs r used to make os then why to write programs for addition of numbers,printing of specific message,etc..How to make os using c language programs.How to make some s/w using C %26amp; to make it in use.
Is C language programs use to make operating system?
Hey - One question at a time.
Try reading this
http://einstein.drexel.edu/courses/CompP...
///
Reply:I guess you need to know about computing concepts first. With C its almost possible to build any software and program you can imagine under the sun, not just the operating systems.
Reply:ooo.. u r one inquisitive soul..
1. Yes there are OS's made in C.. ever heard of UNIX?
2. Its ur will whether to write a program for addition of numbers or not.
3. U can not make OS's using other C programs.. the OS is a program in itself.. well to answer wisely.. u need to learn a bit more about computers first before u start out in the project..
4. U can make a C program using a C editor.. then bundle it up wid the libraries and make it into an exe.. then u r done
Reply:1. Yes! C can be used to write OSes but it is no easy task. Also so part of the OS will usually be written in Assembly Language but the bulk of it is in C. Eg: Linux.
2. An OS is like the foundation of a building. You must have it... what you build on top of it is upto you. Thus the "task" or "duty" of the OS is to provide a suitable platform which can be used to run other programs. Those programs may be as simple as ones for adding two numbers to as complex as a Word Processor or an Action game.
The programs that your write to print messages and add numbers are meant to help you understand concepts and syntax. These programs help you grasp the meaning of printf and scanf so that you are in a position to use these in more complex practical programs.
3. Writing an OS is not an easy job. A large team of expert progammers usually take months or even years to develop a good working OS. For details refer to "Operating System Design %26amp; Impliemntation" by Tanenbaum.
Is C language programs use to make operating system?
Hey - One question at a time.
Try reading this
http://einstein.drexel.edu/courses/CompP...
///
Reply:I guess you need to know about computing concepts first. With C its almost possible to build any software and program you can imagine under the sun, not just the operating systems.
Reply:ooo.. u r one inquisitive soul..
1. Yes there are OS's made in C.. ever heard of UNIX?
2. Its ur will whether to write a program for addition of numbers or not.
3. U can not make OS's using other C programs.. the OS is a program in itself.. well to answer wisely.. u need to learn a bit more about computers first before u start out in the project..
4. U can make a C program using a C editor.. then bundle it up wid the libraries and make it into an exe.. then u r done
Reply:1. Yes! C can be used to write OSes but it is no easy task. Also so part of the OS will usually be written in Assembly Language but the bulk of it is in C. Eg: Linux.
2. An OS is like the foundation of a building. You must have it... what you build on top of it is upto you. Thus the "task" or "duty" of the OS is to provide a suitable platform which can be used to run other programs. Those programs may be as simple as ones for adding two numbers to as complex as a Word Processor or an Action game.
The programs that your write to print messages and add numbers are meant to help you understand concepts and syntax. These programs help you grasp the meaning of printf and scanf so that you are in a position to use these in more complex practical programs.
3. Writing an OS is not an easy job. A large team of expert progammers usually take months or even years to develop a good working OS. For details refer to "Operating System Design %26amp; Impliemntation" by Tanenbaum.
Subscribe to:
Posts (Atom)