Solved

Newbie - Returning Strings ?

Posted on 1997-03-05
1
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCANF - LIMIT THE NUMBER OF CHARARACTERS 1 68
Problem to show menu 5 97
gdb doesn't stop on breakpoint 2 114
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 77
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

733 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