Programming, for all ages and all languages.
Mehmetdev1
Posts: 23 Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 » Fri Apr 08, 2022 2:17 pm
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 (11.57 KiB) Viewed 2429 times
M. Alp
Mehmetdev1
Posts: 23 Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 » Fri Apr 08, 2022 2:40 pm
Octocontrabass wrote: You forgot a ";" on a different line.
No, The error is not that, I tried it myself.
M. Alp
Mehmetdev1
Posts: 23 Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 » Fri Apr 08, 2022 3:25 pm
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
M. Alp
klange
Member
Posts: 679 Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange
Post
by klange » Fri Apr 08, 2022 3:27 pm
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.