[ create a new paste ] login | about

Link: http://codepad.org/YCgouLky    [ raw code | output | fork ]

C, pasted on Mar 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int len = 0;
char str1(char string){
    char *p = &string;
    while(1){
        p = &string;
        if(*p == '\n'){
            break;
        } else {
            &p = &p + 1;
        }       
    }
    return len;
}
int main (void){
    char string = "Trung Dep Trai";
    len = str1(string);
    printf("Value of x = %d\n",len);
}
  


Output:
1
2
3
4
In function 'str1':
Line 10: error: invalid lvalue in assignment
In function 'main':
Line 16: warning: initialization makes integer from pointer without a cast


Create a new paste based on this one


Comments: