Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 19th, 2005, 1:32 AM   #1
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
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
Navid is offline   Reply With Quote
Old Jun 19th, 2005, 6:01 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
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).
grumpy is offline   Reply With Quote
Old Jun 19th, 2005, 9:41 AM   #3
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
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?
Navid is offline   Reply With Quote
Old Jun 19th, 2005, 9:58 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by navnav
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?
Uhmm, MS Visual C++ comes with the libraries of Windows (95 through 2003).

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
nnxion is offline   Reply With Quote
Old Jun 19th, 2005, 1:40 PM   #5
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
Quote:
there are two many platforms that don't have a display at all, so have no need for a GUI.
You mean like electronic devices?

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?
Navid is offline   Reply With Quote
Old Jun 19th, 2005, 3:05 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Jun 19th, 2005, 7:57 PM   #7
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
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
Navid is offline   Reply With Quote
Old Jul 3rd, 2005, 11:56 AM   #8
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 321
Rep Power: 4 mackenga is on a distinguished road
Quote:
Originally Posted by navnav
What about a standard windows application?
A what!? Joking aside, I suggest wxWidgets for a cross-platform GUI development library. I'm no expert; just started scratching the very surface of it recently myself; but it's looking good to me, and will save the time you could waste on Win32.

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.
mackenga is offline   Reply With Quote
Old Jun 20th, 2005, 3:27 AM   #9
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Old Jun 20th, 2005, 3:36 AM   #10
kirkl_uk
Programmer
 
kirkl_uk's Avatar
 
Join Date: Apr 2005
Location: England
Posts: 86
Rep Power: 4 kirkl_uk is on a distinguished road
Send a message via MSN to kirkl_uk
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
kirkl_uk is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC