Solved

Newbie - Returning Strings ?

Posted on 1997-03-05
1
175 Views
Last Modified: 2012-05-04
I am just learning C. How do I return a string to a calling
function ?
I wish to call a function from main and have this function
prompt the user for a 'city code' and then search a
valid codes table. When the user enters a valid code
I wish to return this string value to main and then pass
it to subsequent functions.
Thanks in advance...Neil (carsonn@psac.com)
0
Comment
Question by:carsonn
1 Comment
 
LVL 1

Accepted Solution

by:
Michel021497 earned 50 total points
ID: 1249412
This is the layout of a function returning a string.
In the function you create a string s.
At the end of the function you return s.

char *function()
{
   char *s;
   your code
   return s
}
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question