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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:02:47+00:00 2026-05-31T02:02:47+00:00

Hi something really strange is happening in the following simple program. The program takes

  • 0

Hi something really strange is happening in the following simple program. The program takes ASCII numbers of 2 digits because i only need to read numbers, the ‘@’ symbol and the ‘.’ symbol. And finds out what is the ASCII symbol for this bytes.

int main(int args, char* argv[])
{
 unsigned int ch;


char aux[256];

 strcpy(aux,argv[1]);

 char a[0];

 char buff[50];
 char result[512];
 int i=0;

 while(i lessThan strlen(argv[1]))
 {   
     a[0]=aux[i];
     a[1]=aux[i+1];
     a[2]='\0';
     ch = atoi(a);
      printf("el int:%d \n",ch);
      sprintf(buff,"%c",ch);

       printf("el char: %s \n", buff);
       i=i+2;
   }

 } 

Ok this is working and in the variable buff is printing all the ASCII symbols the right way. But as u can see i have a char[] called result that is never used. So i delete it. and i get a different result when i run the program again :O. For some reason the program does not read the ‘.’ character any more 🙁 WHY???? please someone explain me i am scared lol!

my results with variable result declare:

 ./try3 494650526450

    el int:49

    el char: 1 

    el int:46 

    el char: . 

    el int:50 

    el char: 2 

    el int:52 

    el char: 4 

    el int:64 

    el char: @ 

    el int:50 

    el char: 2 

my results with out variable result declare:

 ./try3 494650526450

    el int:49 

    el char: 1 

    el int:0 

    el char:  

    el int:50 

    el char: 2 

    el int:52 

    el char: 4 

    el int:64 

    el char: @ 

    el int:50 

    el char: 2 
  • 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-31T02:02:48+00:00Added an answer on May 31, 2026 at 2:02 am

    You’re using a zero-length array, a GNU extension. Change char a[0]; to char a[3];. Declaring another unused char array changes the layout of the memory, that’s why it appears to “work”.

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

Sidebar

Related Questions

I'm seeing something really strange happening with some projects I'm working on. I used
Something really weird is happening to my Rails app. For some strange reason, jQuery
I'm experiencing something really strange! I have a div that I'm hiding with JS
I am probably overlooking something really simple here but I am trying to redirect
I'm doing something really simple: slurping an entire text file from disk into a
This is probably something really simple, however I am quite new to PHP, and
This is probably something really simple but I cant see what! Any images I
No doubt I'm missing something really simple here but I just can't see the
I'm experiencing something really strange: I have a NSArray category (with some methods I
Occasionally I am getting a really strange crash in the simulator only (<= 4.3).

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.