473,652 Members | 3,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Structure usage issue

Hi there!

I'm presented with the following situation:

I'm writing a server program that receives information and saves it to
a structure i've created that goes by the name of tabela.

The entire program has 6 files:

projecto.h
serv.h
servsql.h
linkedlist.c
serv_aux.c
servsql.c // this is were main() is

My issue is, i've declared the structure tabela in the file linkedlist.
I can use the functions defined in linkedlist in servsql (were main
is), but i cannot create a variable of the type tabela there... What is
wrong??? I've searched the web for some tutorial but failed to find any
result. Thanks in advance for any help. Bellow you can see the
beginning of every file.

Regards

Pedro Pinto
------------------------------
projecto.h
------------------------------
#ifndef PROJECTO_H
#define PROJECTO_H
#define BUFFSIZE 6804
#define LENGTH 4
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <sys/time.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>

#endif

------------------------------
servsql.h
------------------------------
#ifndef SERVSQL
#define SERVSQL

#include "linkedlist .c"
#include "serv_aux.c "
#include "servsql.c"

int main(int argc, char* argv[]);

void syntax();

void checkParameters (int argc);

void checkPort(int porto_servidor) ;

#endif

-----------------------------
serv.h
-----------------------------

#ifndef SERV_H
#define SERV_H
#include "projecto.h "

void syntax();

void checkParameters (int argc);

void checkPort(int porto_servidor) ;

void printMessage(ch ar buff[]);

void trataMsgCreateI nsert(char array[], char result[]);

void trataMsgUpdateS elect(char array[], char result[]);

int criaMensagem(in t id, int cod, char pedido[], char *buffer);

void getPedido(char buf[], char result[]);

int getId(char buf[]);

int getCod(char buf[]);

int getSizeQuery(ch ar buf[]);
------------------------------------
servsql.c
------------------------------------

#include "serv.h"
/* Função Main */
int main (int argc, char *argv[]) {

------------------------------------
serv_aux.c
------------------------------------

#include "serv.h"
------------------------------------
linkedlist.c
------------------------------------

#include "projecto.h "

typedef struct tabela tabela;
struct tabela {
char nome[50];
int nColunas;
int nLinhas;
char nomeColunas[10][50];
char valores[50][10][65];
tabela *next;
};

Dec 5 '06 #1
2 2100
Pedro Pinto wrote:
Hi there!

I'm presented with the following situation:

I'm writing a server program that receives information and saves it to
a structure i've created that goes by the name of tabela.

The entire program has 6 files:

projecto.h
serv.h
servsql.h
linkedlist.c
serv_aux.c
servsql.c // this is were main() is

My issue is, i've declared the structure tabela in the file linkedlist.
I can use the functions defined in linkedlist in servsql (were main
is), but i cannot create a variable of the type tabela there... What is
wrong??? I've searched the web for some tutorial but failed to find any
result. Thanks in advance for any help. Bellow you can see the
beginning of every file.
Put common declarations like the tabela into one of the header files
and include it from servsql.c. If you want to use an opaque structure
then you must provide accessor functions.

Dec 5 '06 #2
Pedro Pinto wrote:
>
I'm writing a server program that receives information and saves
it to a structure i've created that goes by the name of tabela.

The entire program has 6 files:

projecto.h
serv.h
servsql.h
linkedlist.c
serv_aux.c
servsql.c // this is were main() is

My issue is, i've declared the structure tabela in the file
linkedlist. I can use the functions defined in linkedlist in
servsql (were main is), but i cannot create a variable of the
type tabela there... What is wrong??? I've searched the web for
some tutorial but failed to find any result. Thanks in advance
for any help. Bellow you can see the beginning of every file.
Most of your post is off-topic, because it refers to things unknown
to standard C. To start with, all the following headers are
unknown:

#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>

but there is a larger C question here. If you defined your
"tabela" in linkedlist.c, and need that definition elsewhere, you
need to publish it in the interface definition for linkedlist.c.
The usual way to do this is to place the definition in
linkedlist.h, and #include "linkedlist .h" in every .c file that
needs to know about it.

The purpose of .h files is to expose the portions of the
corresponding .c file that you wish known elsewhere. You also
#include "linkedlist .h" in linkedlist.c to ensure that it also uses
the same definitions or prototypes. You then #include
"linkedlist .h" in each .c file that needs to access those
definitions or prototypes.

Think of the .h file as the link between independent .c files. Not
as a convenient place to stuff prototypes etc. You *never* declare
variables or function bodies in a .h file. Also get in the habit
of marking all functions and file scope variables (in the .c file)
which you do not wish to expose as static.

Before posting again here, read the links below:

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt >
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)
<http://www.dinkumware. com/refxc.html (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net (C-info)
Dec 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3269
by: MM | last post by:
Hi, First off, I'm just beginning .NET and GUI stuff and am very inexperienced. I have worked through a number of GUI tuts in books but all the GUI code to handle events for all the controls in these examples is always in the single file of the main form. What is the correct way to 'sub-divide' various GUI sections into differnet files? For instance, with all my anticipated controls, this one file would be hundreds if not thousands of...
3
3500
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust ------------------------------------------------------------------------
8
1668
by: Jack Russell | last post by:
I do not need this now but it did make me wonder In VB 6 if I define the following structure Public Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long
22
31963
by: Paul | last post by:
Hi I am having a real issue with CPU usage by SQL Server, and it is not related to a poor query. I have a clients database that I am currently investigating some issues with. After I perform a standard task using the application, and the results have been returned to the application the cpu usage remains at 100%.
2
1951
by: James | last post by:
Hi, I need help with a couple of questions, I have create and structure like: Structure byteArray Public byteA() As Byte End Structure Public ptrArray() As byteArray
10
2086
by: rdemyan via AccessMonster.com | last post by:
My app contains utility meter usage. One of the things we have to deal with is when a usage is clearly incorrect. Perhaps someone wrote the meter reading down incorrectly or made a factor of 10 error when entering the reading, etc. At other times the usage is zero or somehow was entered as a negative number. So I'm thinking about adding functionality to search for such anomalies. For instance, show months where the meter reading is...
3
3522
by: san | last post by:
we cannot stop the application from increasingly use memory. The CRM Worker process will continually consume memory but not release it back to the system. Please research into how to make the application consume less memory or at least release the memory when it is done processing a request. It seem like you can be logged in for any amount of time without an issue, I've been told you shouldn't be logged out until idle for 2 hours but...
10
6678
by: Daniel Peterson | last post by:
I'm responsible for a pair of IIS 6 webservers that run our production ASP.Net application. We push code on a monthly basis, and about two weeks after our October code push, we started to run into occasional webserver errors. The application pool is configured to run as a domain user which has permissions to the web code. When we have issues, the webserver will return the ASP.Net "Server Application Unavailable" page, and our app pool...
76
4100
by: jacob navia | last post by:
Since standard C doesn't provide any way for the programmer to direct the compiler as to how to layout structures, most compilers provide some way to do this, albeit in different forms. Microsoft (and lcc-win) uses #pragma pack(1) Gcc uses __attribute__ {(packed)}
0
8367
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.