Thread: I wrote the code, but codeblocks didn't compile anything...?

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    46

    I wrote the code, but codeblocks didn't compile anything...?

    Code:
    #include<stdio.h>
    #include<string.h>
    
    
    
    
    main()
    
    
    {
    
    
    char Kid1[12];
    char Kid2[] = "Maddie";
    char Kid3[7]= "Andrew";
    char Hero1= "Batman";
    char Hero2[34]= "Spiderman";
    char Hero3[25];
        Kid1[0] = 'K';
        Kid1[1] = 'a';
        Kid1[2] = 't';
        Kid1[3] = 'i';
        Kid1[4] = 'e';
        Kid1[5] = '\0';
    
    
        strcpy(Hero3, "the incredible HULK");
    
    
        printf("%s\'s favorite hero is %s.\n", Kid1, Hero1);
        printf("%s\'s favorite hero is %s.\n", Kid2, Hero2);
        printf("%s\'s favorite hero is %s.\n", Kid3, Hero3);
    
    
        return 0;
    
    
    
    
    
    
    
    
    
    
    
    
    }
    I wrote that in and it did run and compile. But the screen was just black? Was that suppose to happen? I am using codeblocks...

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,737
    You need to turn warnings on.

    Code:
    char Hero1= "Batman";
    How many characters can Hero1 hold?

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by Hodor View Post
    You need to turn warnings on.

    Code:
    char Hero1= "Batman";
    How many characters can Hero1 hold?
    What do you mean by "warnings"? Also, I fixed the character count for hero1 and it compiled the way it should have. Thanks!

  4. #4
    Registered User
    Join Date
    Aug 2019
    Location
    Inside a Singularity
    Posts
    239
    You might wanna look at a few resources to learn more about warnings.

    Here are a few good ones:
    Why Bother with Compiler Warnings? - Cprogramming.com
    0.11 — Configuring your compiler: Warning and error levels | Learn C++
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to more intuitively wrote more elegant c++ code?
    By Tesp in forum C++ Programming
    Replies: 13
    Last Post: 07-26-2016, 03:58 PM
  2. Replies: 25
    Last Post: 01-29-2015, 01:41 AM
  3. My code is doing stuff that I didn't tell it to do!
    By Programmer_P in forum C++ Programming
    Replies: 12
    Last Post: 01-14-2011, 07:10 PM
  4. Cant compile using Codeblocks 10.05
    By laimaretto in forum Windows Programming
    Replies: 2
    Last Post: 12-15-2010, 12:24 PM
  5. I wrote a piece of code, can't find where is the bug....
    By meili100 in forum C++ Programming
    Replies: 7
    Last Post: 06-08-2007, 11:25 AM

Tags for this Thread