Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

?'s About What To Do After Learning The General Syntax of C 1

Status
Not open for further replies.

lanems

Technical User
Jan 8, 2002
1
US
Hi Everybody !

I am trying to teach myself C and have a few questions about moving on past the stage of learning the general syntax stuff. I've used VB and MSAccess before to create database type applications. Thanks for your help !!!!

1. How do you create a GUI with menus (a menu bar along the top of the screen would be nice) and data entry fields ?

2. How do you manipulate screen and font colors ?

3. If I made a database type application in C, Would it be better to "write to" and "search and retrieve from" a text file or somehow connect to a windows type of database, such as msaccess (think of a application that 10 to 20 people might use over an intranet - fileserver) ?

4. All of the books about C that I've looked at use really simple sample code that produced just a few lines of output. There must be something more to do that input numbers and sorting. If it isn't pratical to create database apps using C, then what else can someone do with C ?

Sorry about the newbee type questions !

Thanks again !
 
Creating GUI projects is rather painful using straight C.

If you are using Microsoft Visual Studio, you can create a "Win32 Application" using the AppWizard, but it doesn't include the menu bar or even a dialog area where you can drag and drop controls, such as listboxes or other user interface components. Each item must be created through code.

However, using C++ with MFC makes GUI programming a LOT easier. You can create an "MFC AppWizard (exe)" project using the AppWizard, and you have the choice of creating several types of applications. One is a Dialog box, which, once created, automatically includes the menu and an area where you can add controls, such as listboxes, with "drag and drop" ease (just like VB). Of course, you have to program for events (mouse clicks, resizing, etc.), but it's much simpler than just programming Win32 in straight C.

So, if you want to do GUI applications (unless you're doing this strictly for the learning experience), I'd suggest either sticking with VB or going right to Visual C++ using MFC.

2) Everything is a bit harder in C and even C++ than it was in VB. In C++, even when using MFC (which simplifies the C++ Windows programming interface), changing font color requires several steps. First, you to create a CFont object, filling a structure with attributes (color, size, style) and apply it before you can use the new font. However, you get used to that.

3) I would highly recommend learning how to do both file access AND database access for storing information. File access is much easier to program, but most serious applications require database access to allow multiple people to access the data over the network (or even the internet, as you mentioned).

4) You're right. Most tutorials and books use very simple examples. But here's really how most applications are designed today. The front end (what the user sees, or the client GUI application) is almost always written using VB (although browser based front ends are becoming more common). The client application be built to do one of two things. It can either:

a) communicate directly with the database
b) communicate with one or more server based applications that communicate with the database on behalf of the client.

One advantage of having the client communicate with Server application(s) (rather than directly with the database) is that very little (if any) of the business logic has to be built into the client. The business logic (accessing/updating databases) is built into the (non-GUI) server applications, which are often C or C++ applications. Now that's where C really shines... when you can simply use it to create console applications that don't have a Windows user interface and that even can run silently without a DOS interface.

Anyway, I hope my abstract thoughts help you in some imperceptible way. :cool:
 
It is indeed possible to create GUI's with C. Allthough as programsecrets mentioned it's a pain. I personally use borland 5.5 to create windows applications, and C actualy works out better than C++ is some cases. When it comes to any kind of database or string handling though, I would say stay away from C, go to C++. As far as useing text files for a database structure, I'd recomend useing SQL, it's more widely used and a LOT more reliable than Access. There are tutorials out there for programing Win32 useing C/C++ (without Visual Studio even!). I'm at work right now, but later tonight I'll post a few addresses.

Good luck to you, I hope you make it ;)
Rob
"Programming is like art...It makes me feel like chopping my ear off."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top