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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:15:22+00:00 2026-05-18T22:15:22+00:00

I have been trying to create an iphone app sending telnet command. However what

  • 0

I have been trying to create an iphone app sending telnet command. However what puzzling me is that the sizes of certain strings are so much different, particularly when they include \n or \r. I listed out a few examples. Please assist.

const char *a = "play 25\n";
int sizeBitA1 = sizeof(a);  // 8 units
int sizeBitA2 = sizeof("play 25\n"); // 9 units
const char *b = "\r\n";
int sizeBitB1 = sizeof(b);  // 8 units
int sizeBitB2 = sizeof("\r\n");  // 3 units
  • 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-18T22:15:23+00:00Added an answer on May 18, 2026 at 10:15 pm

    The following code snippet illustrates all the options of using string constants, arrays and pointers, and sizeof and strlen.

    const char *a   = "play\n";
    const char at[] = "play\n";
    int sizeBitA1 = sizeof(a);  // 8 bytes == size of a pointer
    int sizeBitA2 = sizeof("play\n"); // 6 bytes, including the trailing '\0'
    int sizeBitA3 = sizeof(at); // 6 bytes, including the trailing '\0'
    int sizeBitA4 = strlen(a);  // 5 bytes, excluding the trailing '\0'
    int sizeBitA5 = strlen("play\n"); // 5 bytes, excluding the trailing '\0'
    int sizeBitA6 = strlen(at); // 5 bytes, excluding the trailing '\0'
    const char *b = "\r\n";
    const char bt[] = "\r\n";
    int sizeBitB1 = sizeof(b);  // 8 bytes == size of a pointer
    int sizeBitB2 = sizeof("\r\n");  // 3 bytes, including the trailing '\0'
    int sizeBitB3 = sizeof(bt);  // 3 bytes, including the trailing '\0'
    int sizeBitB4 = strlen(b);  // 2 bytes, excluding the trailing '\0'
    int sizeBitB5 = strlen("\r\n");  // 2 bytes, excluding the trailing '\0'
    int sizeBitB6 = strlen(bt);  // 2 bytes, excluding the trailing '\0'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an app and I'm nearly complete. I have been trying
I have been trying to create a simple calculator. Using PHP I managed to
I have been trying to create a directory in /sdcard programmatically, but it's not
I have been trying to create a timer program with VB 2010 to the
Over the past few days I have been trying to create/run a project in
I am writing a google reader application and have been trying to create the
I have been trying to find out total count of rows in each tables
I'm trying to submit my first app to the app store. When I compile
I have a MySQL Database of more or less 100 teachers, their names, and
What does mean? I get this error when trying to iterate through a file

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.