What does this code do?? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

What does this code do??

Panasonic99Panasonic99 Posts: 140Member
When this program is run, the user enters: /b/b/b/bSTOP
( /b denotes a space is entered)

void bump (char[]);

void main()
char str[20];
printf("Enter a string: ");
scanf("%s", str);
printf("%s", str);

void bump (char A[])
int i = 0;
while (A[i] ! = '')
if (i % 2 == 0)
A[i] = 'X';
A[i] = 'B';

what should this produce and why, I think something may be wrong with my editor



  • stoberstober Posts: 9,765Member ✭✭✭
    compile and run the program to find out what it does. Your program contains a suttle error -- scanf() can cause buffer overflows and crash your program because it does not limit the number of characters you can type.
  • Panasonic99Panasonic99 Posts: 140Member
    what does it produce and why- my compiler isnt working can you please just tell me?

  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2005-8-8 10:31:38[/red][/b][hr]
    : what does it produce and why- my compiler isnt working can you please just tell me?
    : thanks

    No. what does that mean -- your compiler doesn't work?
    get a compiler that works -- they are free for the downloading.

  • Panasonic99Panasonic99 Posts: 140Member
    Can someone please tell me what this code produces and why? thanks
  • DB1DB1 Posts: 1,142Member
    : Can someone please tell me what this code produces and why? thanks

    I agree with Stober. You need to get a compiler that works and test code out yourself. There's no way you can learn real-life implementations without it.

    Try installing Dev-C++ because it's decent and it's free.

    [italic][blue]To understand recursive, first you need to understand recursive[/blue][/italic]

  • Chainsaw666Chainsaw666 Posts: 198Member
    DB1 and Stober are both telling you exactly what to do, there are literally thousands of free compilers readily available on the Internet, all you need to do is pick one and use it. Dev-C++ is a very popular and very good compiler for the Win32 platform. You could also download Open Watcom C/C++ which supports just about every imagineable target, and has support for assembly, C, C++, and even FORTRAN if that's your cup of tea. And there are older ones for DOS, like Pacific C, a very good compiler for anything that runs DOS, such as Win 98. Go out there, download one, and use it (and don't give me crap about it being too large to download, I downloaded Dev-C++ (5.2 megs) and Open Watcom (62 MB) on a 26.6 Kbps dial-up modem). If worst goes to worst, or you get really confused, there is always paper, just work it out step by step, you should know what all the lines of code do already, you did write them after all.
Sign In or Register to comment.