03-C-not-so-basics

03-C-not-so-basics - 03 Lecture C(not so basics-Reading...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
03 - Lecture - C (not so) basics --------------------------------- Reading: - Chapter 5,6 C vs. Java ----------- C: - prog.c (source file) ---- [compiler] ----> prog.o (object file) - multiple object files ---- [linker] ----> executable file - objects and executables are CPU-specific and OS-specific Java: - prog.java (source file) ---- javac ----> prog.class (byte code) - "java" (or java.exe) is the actual executable, which implements the Java Virtual Machine (JVM) - JVM runs a java program by translating machine-independent byte code into CPU/OS-specific machine instructions on the fly Variable scoping ----------------- int x; x = 0; { int x; x = 1; } printf("%d", x); Storage class -------------- 1) automatic variables - also called stack variables, since they are usually stored in process stack (we’ll see what this means later) - scope: local to a block - lifetime: created on block entrance, destroyed on exit - example: int foo(int auto_1)
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
{ int auto_2; { int auto_3; ... } ... } 2) static variables - "static" has so many meanings in C/C++/Java, so brace yourself! - stored in global data section of process memory - scope depends on where it is declared: global, file, or block
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern