Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 638625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:45:11+00:00 2026-05-13T20:45:11+00:00

int cpu = 0; int player = 0; char * getPoints() { using namespace

  • 0
int cpu = 0;
int player = 0;

char * getPoints()
{
    using namespace std;
    string str = "You: ";
    str += player;
    str += " CPU: ";
    str += cpu;
    char c [100];
    strcpy(c, str.c_str());
    return c;
}

This code doesn’t compile. Is the code wrong or is there something wrong with my compiler?

I’m using Microsoft Visual Studio with the DarkGDK.

If it is me, can someone improve it?


This is the output:

1>------ Build started: Project: Pong, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\users\martijn\documents\visual studio 2008\projects\pong\pong\main.cpp(42) : warning C4172: returning address of local variable or temporary
1>Linking...
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(stdthrow.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z)
1>Debug\Pong.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Martijn\Documents\Visual Studio 2008\Projects\Pong\Pong\Debug\BuildLog.htm"
1>Pong - 4 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:45:11+00:00Added an answer on May 13, 2026 at 8:45 pm

    The errors seem to be from problems with the compiler. Are you sure you have the project set up correctly?

    The warning about returning a local variable is serious. You allocate the c array on the stack in your function. When the function returns, the array will be gone from the stack and the pointer you returned ends up pointing to garbage. Consider returning a string instead, or allocate c on the heap.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double
int main(void) { char testStr[50] = Hello, world!; char revS[50] = testStr; } I
int a[2]; This in memory actually looks like: //Assuming int is 2 bytes add=2000,
int main() { char *p,c; for(p=Hello World;c=*p;++p) { printf(%c,c); } } In the above
Is there significant cpu/memory overhead associated with using automatic arrays with g++/Intel on 64-bit
I'm running the following benchmark: int main(int argc, char **argv) { char *d =
What requires the most CPU: int foo = 3; or typecasting it to an
Consider: #include <map> int main() { std::map< int, int > m; m[ 0 ]
public class Players { public int GUID { get; set; } public string Name
I'm trying to get the CPU% for all processes in parallel using C#'s TPL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.