User Profile

Collapse

Profile Sidebar

Collapse
karan173
karan173
Last Activity: Apr 10 '12, 09:51 PM
Joined: Dec 30 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • karan173
    started a topic Why is this simple program not working?
    in C

    Why is this simple program not working?

    Code:
    #include<stdio.h>
    
    int main()
    {
        char *s="hello";
        *(s+2)='a';
        printf("%s",s);
    	return 0;
    }
    it gives a runtime error, however if i declare s as a character array like s[]="hello", it works, why?
    See more | Go to post

  • hmm, thanks for ur response, solved myself after some effort, as i said the toggling code was not correct
    See more | Go to post

    Leave a comment:


  • karan173
    started a topic k&r chapter-1 question, creating a syntax checker
    in C

    k&r chapter-1 question, creating a syntax checker

    hey it is required to create a syntax checker which reports about common errors like unbalanced paranthesis etc. i hav created d following code, which complies finely and produces correct output for generally, but when i enter d source code as input, it produces wrong input, so csn u help me find d bugs:-
    Code:
    #include<stdio.h>
    #define IN 1
    #define OUT 0
    int main()
    {
        int c=0,prevc=0,prevprevc=0,sstate=OUT,dstate=OUT,cstate=OUT,count[256],boo=OUT,i=0,asciieq=0,line=0;
    ...
    See more | Go to post
    Last edited by Stewart Ross; Dec 30 '11, 02:31 PM. Reason: Corrected code tags - from <code> to [code]
No activity results to display
Show More
Working...