Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VC++ dll error: not all control paths return a value

Posted on 1999-07-13
4
Medium Priority
?
288 Views
Last Modified: 2008-03-06
I am getting an error that says "not all control paths
return a value."

char *Getinfo(char *name, int length, int number, char *string)
{
    char* temp = new char[100];
    name = temp;
    int flag = 0;
    if (flag == 0)
     {
        return temp;
     }
}

I'm not sure if i'm returning the character string correctly

thanks

   
0
Comment
Question by:pesst
[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
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 80 total points
ID: 1199980
Simply change the code to read

char *Getinfo(char *name, int length, int number, char *string)
{
    char* temp = new char[100];
    name = temp;
    int flag = 0;
    if (flag == 0)
     {
        return temp;
     }

// the missing control path is here ...
return ( <whatever is appropriate in this case...>);
}
0
 
LVL 86

Expert Comment

by:jkr
ID: 1199981
BTW:

    int flag = 0;
    if (flag == 0)  // this is always TRUE!!
     {
        return temp;
     }

I assume there should be some more code between the initialization of 'flag' and the 'if' clause...
0
 
LVL 2

Author Comment

by:pesst
ID: 1199982
Stupid mistake had me stuck for an hour

thanks!
0
 
LVL 2

Author Comment

by:pesst
ID: 1199983
i know i just didn't want to post my real code
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

721 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