Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C code. There are bugs in it. Please explain me what/where is wrong and how to write the right code. stringhelp.h #pragma once #ifndef STRINGHELP_H

C code. There are bugs in it.

Please explain me what/where is wrong and how to write the right code.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

stringhelp.h \#pragma once \#ifndef STRINGHELP_H \#define STRINGHELP_H \#define MAX_STRING_SIZE 511 \#define MAX_INDEX_SIZE 100 \#define MAX_WORD_SIZE 23 struct StringIndex \{ char str[MAX_STRING_SIZE +1]; int wordStarts[MAX_INDEX_SIZE]; int lineStarts[MAX_INDEX_SIZE]; int numberStarts[MAX_INDEX_SIZE]; int numWords, numLines, numNumbers; \} ; / * Return the index of the next whitespace. * @param str - the string to search * areturns the index of the next white space or the position of the string terminator. *) int nextWhite(const char* str); * @param word - where the result will be placed * aparam idx - the index to use * aparam wordNum - the index of the number to retrieve * areturns the number or an empty string if index is invalid */ void getNumber(char word[], const struct StringIndex* idx, int numberNum); /** * Return a pointer to the start of a line * aparam idx - the index to use * aparam lineNum - the index of the line to retrieve * areturns a pointer to the start of the line */ char* getLine(struct stringIndex* idx, int lineNum); /** * Prints characters until the terminator is found. * @param s - the string to print * aparam start the index to start printing * aparam terminator - the character to stop printing at when encountered. */ void printUntil(const char* s, const int start, const char terminator); /** * Prints characters until a space is found. * aparam s - the string to print * aparam start - the index to start printing */ void printUntilspace(const char* s, const int start); \#endif stringhelp.c \#define _CRT_SECURE_NO_WARNINGS \#include "stringhelp.h" \#include \#include \#include int nextWhite(const char* str) inti,result=1; for (i=0;result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

What are the first signs that a person might be depressed?

Answered: 1 week ago

Question

What is the use of bootstrap program?

Answered: 1 week ago

Question

What is a process and process table?

Answered: 1 week ago

Question

What is Industrial Economics and Theory of Firm?

Answered: 1 week ago

Question

manageremployee relationship deteriorating over time;

Answered: 1 week ago