Error expected ‘;’ before while error

Programming, for all ages and all languages.
Post Reply
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Error expected ‘;’ before while error

Post by Mehmetdev1 »

Hello, Error expected ‘;’ before while error How can I fix the problems and I will share the screen of the error.

Code: Select all

void printf(char* str)
{

    unsigned short* VideoMemory = (unsigned short*)0xb8000;

    for(int i = 0; str[i] != '\0'; ++i)
    VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];

}


void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
    printf("Kapiler İsletim Sistemi")

    while(1);

}
Attachments
Ekran görüntüsü 2022-04-08 231251.png
Ekran görüntüsü 2022-04-08 231251.png (11.57 KiB) Viewed 2426 times
M. Alp
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Error expected ‘;’ before while error

Post by Octocontrabass »

You forgot a ";" on a different line.
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Error expected ‘;’ before while error

Post by Mehmetdev1 »

Octocontrabass wrote:You forgot a ";" on a different line.
No, The error is not that, I tried it myself.
M. Alp
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Error expected ‘;’ before while error

Post by Octocontrabass »

Yes it is. You forgot the ";" on the previous line.
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Error expected ‘;’ before while error

Post by Mehmetdev1 »

When I put a semicolon in the previous line, it gives an error as follows. I will send the screenshot and code to the message.

Code: Select all

void printf(char* str)
{

    unsigned short* VideoMemory = (unsigned short*)0xb8000;

    for(int i = 0; str[i] != '\0'; ++i)
    VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];

}


void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
    printf("Kapiler İsletim Sistemi");

    while(1);

}
Attachments
Ekran görüntüsü 2022-04-09 002445.png
M. Alp
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Error expected ‘;’ before while error

Post by klange »

Mehmetdev1 wrote:When I put a semicolon in the previous line, it gives an error as follows. I will send the screenshot and code to the message.
There is no error in your screenshot. You are getting a warning because string constants are const char* and you are passing one to a function that just takes char * which C++ does not like.
Post Reply