![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hobbyist Programmer
|
Programing Graphic Applications (solved)
I've read half of "SAMS teach yourself C in 21 days" and I'm still clueless on how to program graphic applications. I only know how to program a console application with only text. Even a simple tic-tac-toe game i would be intrested in programming.
I am knowledgable with: variables types and scope, manupilating arrays,pointers,structers,unions, functions and passing arguments, for while do...while loops, switches (of course with the help of PF )maybe more but i cant remember Here's a program i made that has almost everything i know /* Everything i know */
#include <stdio.h>
#define QUIT 7
int dim(int arg,int arg2,int arg3),bigger(),radius(float arg);
int pointer_use(int arg1,int arg2);
int structure(void);
int *pointer1,*pointer2;
char name[];
int choice;
int count;
int dim1,dim2,dim3;
int num[2];
int set1[5],set2[5];
float rad;
int main()
{
while (choice != QUIT)
{
printf("Welcome %s",name);
printf("\n//////\tList\t//////");
printf("\n1 - 3 Dimensional Array");
printf("\n2 - Bigger Number");
printf("\n3 - Radius");
printf("\n4 - Pointer Use");
printf("\n5 - Enter your name");
printf("\n6 - Structure");
printf("\n7 - Quit\n");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf("\nDimension 1:");
scanf("%d", &dim1);
printf("\nDimension 2:");
scanf("%d", &dim2);
printf("\nDimension 3:");
scanf("%d", &dim3);
dim(dim1,dim2,dim3);
break;
case 2: bigger();
break;
case 3:
printf("\nEnter a radius\n");
scanf("%f", &rad);
printf("\nThe area of that circle is %d\n\n", radius(rad));
break;
case 4:
puts("\nEnter the 5 numbers for the first set\n");
for (count=0; count<5; count++)
{
scanf("%d", &set1[count]);
}
puts("\nEnter the 5 numbers for the second set\n");
for (count=0; count<5; count++)
{
scanf("%d", &set2[count]);
}
pointer_use(set1,set2);
printf("\nThe Sum of the two set of arrays are %d and %d\n\n", *pointer1,*pointer2);
break;
case 5:
printf("\nEnter your name\n");
getchar();
gets(name);
printf("\n");
break;
case 6:
structure();
break;
default: printf("\nSelect a number from the list please\n\n");
}
}
return 0;
}
int dim(int arg1,int arg2,int arg3)
{
int a=0,b=0,c=0;
int array[1][1][1];
int count = dim1*dim2*dim3-1;
for (a=0; a<dim1; a++)
{
for (b=0; b<dim2; b++)
{
for (c=0; c<dim3; c++)
{
printf("\nArray[%d][%d][%d] = %d",a,b,c, dim1*dim2*dim3-count--);
}
}
}
printf("\n\n");
}
int bigger()
{
int bigger=0, count=0;
printf("\n Enter 2 numbers\n");
scanf("%d %d", &num[0], &num[1]);
while (count<2)
{
if (num[count] > bigger)
{
bigger = num[count];
}
count++;
}
printf("\nThe bigger number is %d\n\n", bigger);
}
int radius(float arg)
{
float area = 3.14*rad*rad;
return area;
}
int pointer_use(int arg1,int arg2)
{
int sum1=0,sum2=0,count;
pointer1 = &sum1;
pointer2 = &sum2;
for(count=0; count<5; count++)
{
sum1 += set1[count];
}
for(count=0; count<5; count++)
{
sum2 += set2[count];
}
}
int structure(void)
{
signed x_dis,y_dis;
struct tag
{
int x;
int y;
}man1_loc,man2_loc;
printf("\nWhere is Man1\'s location?\nx position:");
scanf("%d",&man1_loc.x);
printf("y position:");
scanf("%d",&man1_loc.y);
printf("\n\nWhere is Man2\'s location?\nx position:");
scanf("%d",&man2_loc.x);
printf("y position:");
scanf("%d",&man2_loc.y);
x_dis = man1_loc.x - man2_loc.x;
y_dis = man1_loc.y - man2_loc.y;
if (x_dis < 0)
{
x_dis = x_dis-x_dis-x_dis;
}
if (y_dis < 0)
{
y_dis = y_dis-y_dis-y_dis;
}
if (x_dis >= 100 || y_dis >= 100)
{
printf("\nMan1\'s location:(%d,%d)\n", man1_loc.x,man1_loc.y);
printf("\nMan2\'s location:(%d,%d)\n", man2_loc.x,man2_loc.y);
printf("\nThe two men are far apart\n\n");
}
else
{
printf("\nMan1\'s location:(%d,%d)\n", man1_loc.x,man1_loc.y);
printf("\nMan2\'s location:(%d,%d)\n", man2_loc.x,man2_loc.y);
printf("\nThe two men are close together\n\n");
}
}Should I forget about graphics for now? Last edited by navnav; Jun 20th, 2005 at 1:29 PM. Reason: Solved |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
By "graphics", I assume you mean "graphical user interface" (GUI) rather than (say) writing out a file that can be printed on a printer.
GUI is formally not covered by the C (or C++) standards at all -- and probably never will be; there are two many platforms that don't have a display at all, so have no need for a GUI. That's the theory. Fortunately, the practice is slightly less bleak. What you need to do is pick what operating system you want to target (eg windows, linux, solaris, etc etc). You will then find that there are a lot of development environments that allow you to develop GUI applications (eg Microsoft Visual Studio or products from Borland/Inprise) or libraries (eg under most forms of Unix there are libraries that support developing GUI using X-windows or some variant of that). There are also a lot of libraries available (either free for download or you can buy one) that you can use to build a GUI. That catch is that a lot of GUI is non-portable (unless you program very carefully, or use a library that has been carefully designed so it provides the same programming interface on multiple systems). |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Ok it makes sense to me now. I'll be purchasing a copy of Microsoft Visual C/C++ sooner or later. Im geussing that it comes with the libaries i need right? If not were can I get the appropiate ones?
So when i get Visual C/C++, there'd be alot to cover on using the GUI? Does it come with a tutorial for the GUI? And i heard the 2005 version to be released soon, so ill wait till then. Is there a specific release date right now for it? |
|
|
|
|
|
#4 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
It does not come with a tutorial, the MSDN help does have small tutorials on all sorts of things. A link to GUI programming: http://www.winprog.org/tutorial/. Search google and Microsoft site for any release dates.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
|
Quote:
So what im learning now is aiming towards programming stuff like electronic devices such as thermostates and remotes? But is still essintial to program with a GUI right? |
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
One can program all day without a GUI. Believe me there are hundreds of important commercial devices other than thermostats and remotes that don't have GUIs. How does your mail get sorted? How do you buy a money order down at 7-Eleven? What manufactures batteries from raw materials through tested units in one swell foop? What makes your car run correctly most of the time? The huge majority of the GUIs in use today sit on a desktop. They often increase productivity in their given environment. They weren't handed down from on high.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
What about a standard windows application? Like alerts and just plain text and links on a windows application.
My book on C says nothig about it ![]() |
|
|
|
|
|
#8 | |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 321
Rep Power: 4
![]() |
Quote:
For rapid GUI development, check out Tcl/Tk - I know I bang on about it all the time, but that's because it's excellent. http://www.tcl.tk/ - it's a high level scripting language you can extend with C, and you can embed its interpreter in C applications. Definitely worth a look if you've started with C, anyway; I reckon Tcl/Tk is seriously underrated, and as far as language teams go, you'd have to go a long way to beat C and Tcl for rapid development of efficient (enough) GUI apps on Windows, Mac and Unix. |
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() |
I have only written about 1 or 2 graphical programs in my life and they were on vb and it forces you to, but then i got linux and kinda didnt learn it :/
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#10 |
|
Programmer
|
Your book on C won't say anything about GUIs because it is a book on C programming. C programming and GUI programming are different topics, you just implement GUI programming using C, or whatever.
__________________
kirkl_uk |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|