Thread: hey trying to compile this simple code, don't know wats d error ,do check d output

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    1

    Post hey trying to compile this simple code, don't know wats d error ,do check d output



    Code:
    
    #include<stdio.h>
    void main()
    { char ch;char s[]="Hello"; int loc; printf("Location\n"); scanf("%d",&loc); printf("Enter character to be entered \n"); scanf("%c",&ch); s[loc]=ch ; printf("%s",s); }



  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What is the problem with your code?

    You need to ask specific questions.

    Jim

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    scanf("%d",&loc); left \n in the input stream
    scanf("%c",&ch); read this character.

    FAQ > Flush the input buffer - Cprogramming.com
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wats wrong with this code
    By juice in forum C Programming
    Replies: 3
    Last Post: 12-20-2011, 12:00 PM
  2. Replies: 3
    Last Post: 04-27-2011, 09:46 PM
  3. Why the simple code doesn't compile?
    By meili100 in forum C++ Programming
    Replies: 4
    Last Post: 09-14-2008, 03:28 AM
  4. wats wrong with this code?
    By Marrah_janine in forum C++ Programming
    Replies: 20
    Last Post: 12-10-2006, 08:01 PM
  5. why can I get this simple code to compile?
    By tarotcard in forum C Programming
    Replies: 7
    Last Post: 11-10-2005, 05:20 AM

Tags for this Thread