Program fails because do … while loop needs braces

Program fails because do … while loop needs braces

I’m a beginner in C programming. I have Microsoft Visual C++ 4.0.

I’ve read the book Programming with C by Byron Gottfried.

Unfortunately, no matter which simple program I try to write, I always run into a mistake. The error I make doesn’t seem wrong, so I don’t know what to change …

I’d appreciate it if you could help me with this simple program and tell me what to change. I want to make it so that it inputs characters and stores them as other character (‘a’ as ‘b’, ‘b’ as ‘c’ …. etc.)The error is: (23) : error C2061: syntax error : identifier ‘i’

This is the program:

#include #include main(){	FILE *fpt;	int i;	char c;		/* open file enc.dat as write-only to store coded text */	fpt=fopen(“enc.dat”, “w”);	/* send to ASCII and code */		do		c=getchar();		i=c;		++i;		c=i;		putc(c, fpt);	while (c != ‘%’);	/* close the enc.dat */	fclose(fpt);}

The problem is that you need braces around the body of your do … while loopwrite the do … while block as follows.

do	{		c=getchar();		i=c;		++i;		c=i;		putc(c, fpt);	}	while (c != ‘%’);
and you will be OK.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes