473,473 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Structure return type is an incomplete type.

I have something like this:

#include <stdio.h>
#include <ctype.h>
#include <strings.h>

struct sentence get_sentence (char string[])
{
struct sentence my_sentence
{
int count_1;
int count_2;
int count_3;
};

// Add for-loop to count numbers, uppercase letters (isupper),
//lowercase(islower), etc.

return(mysentence)
}

However, even before i add the for-loop, i cannot compile it. An error
comes up saying that the "return type is an incomplete type".
Basically, the problem asked me to count the number of
uppercase/lowercase letters and digits in a string. Then return that
as a structure.

Thanks.
May 5 '06 #1
2 15082
gk245 submitted this idea :
I have something like this:

#include <stdio.h>
#include <ctype.h>
#include <strings.h>

struct sentence get_sentence (char string[])
{
struct sentence my_sentence
{
int count_1;
int count_2;
int count_3;
};

// Add for-loop to count numbers, uppercase letters (isupper),
//lowercase(islower), etc.

return(mysentence)
}

However, even before i add the for-loop, i cannot compile it. An error comes
up saying that the "return type is an incomplete type". Basically, the
problem asked me to count the number of uppercase/lowercase letters and
digits in a string. Then return that as a structure.

Thanks.


Doh, nevermind, i was supposed to declare the structure and its members
before the function starts, not inside of it.
May 5 '06 #2
gk245 <to*****@mail.com> wrote:
#include <stdio.h>
#include <ctype.h>
#include <strings.h>
The header is <string.h>.
struct sentence get_sentence (char string[])
{
struct sentence my_sentence
{
int count_1;
int count_2;
int count_3;
};


How do you expect this to work? The structure definition is contained
within the function block; you're declaring get_sentence() to return a
structure whose definition is not in scope. Your friendly C text can
explain how to use incomplete types for fun and profit; you can also
simply move your structure definition outside the function (and to an
appropriate header file).

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
May 6 '06 #3

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

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
6
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph...
15
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
2
by: rashmi | last post by:
Hi All, ************************************************* error: variable `hdlc_cdevsw' has initializer but incomplete type *************************************************** This is the error...
9
by: Hank Stalica | last post by:
So I've made a linked list class. I have a function that initiates this class, opens a file, parses it, and then inserts nodes into this temporary class. What I would like to do is then have...
7
by: Pep | last post by:
I'm getting weird results at the moment so thought I'd rebase my knowledge of c++ storage with your help :) I have a class used as a type in a struct and the struct is handled by a 3rd party...
7
by: shantibhushan.sale | last post by:
Hi, Do we have private(not necessary using private keyword) structure in C?
4
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal...
3
by: massysett | last post by:
Greetings, Having classes with member objects that have STL containers of objects whose definitions are incomplete results in undefined behavior. See for example: ...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.