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 8353127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:10:07+00:00 2026-06-09T09:10:07+00:00

I have string,int,float values and trying to assign those values to char* c[] array

  • 0

I have string,int,float values and trying to assign those values to char* c[] array like this.

char *str = "helloo";
int int = 1000;
short st1[]={32760};
float flt = 2.345; 
char*  c [] = {(char*)int1,(char*)str,(char*)flt,(char*)st1};

but for float getting illegal explicit conversion from ‘float’ to ‘char * ‘
anybody tel me how to assign?

  • 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-06-09T09:10:08+00:00Added an answer on June 9, 2026 at 9:10 am

    You can’t just cast those types and expect to get useful results. Casting is a minimal operation which can work to transform data in certain predefined ways, but it won’t (for example) intelligently turn integers into their string representations.

    That’s why your compiler is complaining.

    If you want the string representation of numeric data, you have to convert them differently, with something like:

    char intStr[30]
    sprintf (intStr, "%d", int1);
    

    If you’re looking to get string representations of them all, you can do something like:

    char *str = "helloo";
    int int1 = 1000;
    short st1[]={32760};
    float flt = 2.345; 
    
    char mybuff1[50], mybuff2[50], mybuff3[50], mybuff4[50];
    sprintf (mybuff1, "%d", int1);
    sprintf (mybuff2, "%s", str);
    sprintf (mybuff3, "%f", flt);
    sprintf (mybuff4, "%d", st1[0]);
    
    char *c [] = {mybuff1, mybuff2, mybuff3, mybuff4);
    

    And be aware that, although C and C++ have very similar idioms, and are mostly compatible if you stick to a subset, they are not the same language and the best way to do something changes dramatically depending on the actual language you’re using.

    For example, it’s rarely necessary to use C-style strings in C++ since that language provides an impressive real string type. Ditto for malloc/free as opposed to new/delete and many other aspects.

    Questions should generally be tagged C or C++, rarely both.

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

Sidebar

Related Questions

I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
I have a struct like this: typedef struct { int sizes[3]; float **vals[3]; //
Hi i have created a Generic Array that works fine for Int,String, Float or
I have the following function: public static byte[] StringToByte(string str) { int length =
I have this methods getParam public int getParam(String paramName){ if(paramName.equals(Balls and net)){ expressionParam=1; }
I defined this multi dimensional array in C#: int[,] values = new int[,] {
I am trying to simply write an array of float values to a file
I have a typedef boost::variant<int, float, double, long, bool, std::string, boost::posix_time::ptime> variant which I
I have an instance of dict with int s, float s, string s as
I have tried to do this - Making any float value to int value.

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.