Solved

Newbie - Returning Strings ?

Posted on 1997-03-05
1
173 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Picking random number 8 175
c language help - file paths 7 141
Adjust Mfcapp 29 160
Line meaning 9 82
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now