algebra pointers help

Write your question here.

Hello, i have just to work with pointers and this code is in the example in my book but it crash when i compile it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

  #include <stdio.h>


int main(void) {

    int i = 2;
    int *p;
    p=&i;
    *p=3;
    printf('Ahora i = %d \n', i);

    
    return(0);
}


this is the error logout

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/C++/Ejemplos1'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/ejemplos1.exe
make[2]: Entering directory '/cygdrive/c/C++/Ejemplos1'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++    -c -g -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
main.cpp:23:12: warning: character constant too long for its type [enabled by default]
     printf('Ahora i = %d \n', i);
            ^
main.cpp: In function 'int main()':
main.cpp:23:32: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
     printf('Ahora i = %d \n', i);
                                ^
In file included from /usr/include/stdio.h:29:0,
                 from main.cpp:9:
/usr/include/stdio.h:177:5: error:   initializing argument 1 of 'int printf(const char*, ...)' [-fpermissive]
 int _EXFUN(printf, (const char *__restrict, ...)
     ^
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/C++/Ejemplos1'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/C++/Ejemplos1'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 769ms)

'single quotes' are for character literals
"double quotes" are for string literals

put your string in double quotes, not single quotes.
Topic archived. No new replies allowed.