1. Given the string variables pres, first, and last as defined in Example 9.2 provided on page 459 of your textbook, Problem Solving and Program Design in C, show what would be displayed by this code fragment. (If you do not know, you can always place this code into the proper C coding structure and compile and execute.) Make certain your call includes <stdio.h> and <string.h> and declare your variables if you are going to compile. (Hint:Refer to the text below the first paragraph on p.459 of your textbook for assistance.)
strncpy(first, pres, 2);
first[2] = '\0';
printf("%s", first);
printf("\n");
printf(" %s", strcpy(last, &pres[7]));
strncpy(first, &pres[7], 2);
first[2] = '\0';
strncpy(last, &pres[14], 2);
last[2] = '\0';
printf("\n");
printf(" %s%s\n\n", first, last);
2. Refer to these declarations when determining the effect of the statements in the following questions (record your answers for the results of each bullet):
char s5[5], s10[10], s20[20];
char aday[7] = "Sunday";
char another[9] = "Saturday";
i. strncpy(s5, another, 4);
s5[4] = '\0';
ii. strcpy(s10, &aday[3]);
iii. strlen(another)
iv. strcpy(s20, aday); strcat(s20, another);
v. Which one of the following would call somefun only if the string values of character arrays a and b were equal?
a. if (strcmp(a, b))
somefun();
b. if (strcmp(a, b) == 0)
somefun();
c. if (a == b)
somefun();
d. if (a[] == b[])
somefun();
vi. What does this program fragment display?
char x[80] = "gorilla";
char y[80] = "giraffe";
strcpy(x, y);
printf("%s %s\n", x, y);
a. What does this program fragment display?
char x[80] = "gorilla";
char y[80] = "giraffe";
strcat(x, y);
printf("%s %s\n", x, y);
1. Given the string variables pres, first, and last as defined in Example 9.2 provided on...
You must use C Language. The Main Objective: Make the first and last name ALL CAPITALS even if the user types in lower case letters. Lastly, flip the first name and last name around. So: HEIDI, HATFIELD to HATFIELD, HEIDI. (PLEASE uppercase all the letters) End Goal: HATFIELD, HEIDI KAISER, RUSSELL LIPSHUTZ, HOWARD PENKERT, DAWN WRIGHT, ELIZABETH Please use this reference below, to fix the code given. Code given is below, I want the user to be able to enter...
-I need to write a program in C to store a list of names (the last name first) and age in parallel arrays , and then later to sort them into alphabetical order, keeping the age with the correct names. - Could you please fix this program for me! #include <stdio.h> #include <stdlib.h> #include <string.h> void data_sort(char name[100],int age[100],int size){ int i = 0; while (i < size){ int j = i+1; while (j < size){...
Using the provided Linked List example code, linkedlist.c, as an example Make a node struct that holds ints instead of strings. In your main, insert 25 to 75 random integers with range (0 to 100) into a linked list of your nodes. Use a random to determine how many to make. Write a function int sum(NodePointer current) that returns the sum of the integers in the list by looping through the linked list. Write a function int count(NodePointer current) that...
Please answer problem #5 thank you
str.c
#include "str.h"
#include <stdio.h>
int str_len(char *s)
{
/* this is here so code compiles */
return 0;
}
/* array version */
/* concantenate t to the end of s; s must be big enough */
void str_cat(char s[], char t[])
{
int i, j;
i = j = 0;
while (s[i] != '\0') /* find end of s
*/
i++;
while ((s[i++] = t[j++]) != '\0') /* copy t */
;...
Identify and list all the User defined Functions to be used in the system #include <stdio.h> ///for input output functions like printf, scanf #include <stdlib.h> #include <conio.h> #include <windows.h> ///for windows related functions (not important) #include <string.h> ///string operations /** List of Global Variable */ COORD coord = {0,0}; /// top-left corner of window /** function : gotoxy @param input: x and y coordinates @param output: moves the cursor in specified position of console */ void gotoxy(int x,int y) {...
1. You are given a C file which contains a partially completed
program. Follow the instructions contained in comments and complete
the required functions. You will be rewriting four functions from
HW03 (initializeStrings, printStrings, encryptStrings,
decryptStrings) using only pointer operations instead of using
array operations. In addition to this, you will be writing two new
functions (printReversedString, isValidPassword). You should not be
using any array operations in any of functions for this assignment.
You may use only the strlen() function...
Please help in answering these questions dealing with this one
prompt:
1
Which line is first line of the date structure prototype
(blueprint)?
30
21
7
59
2
Which line is date structure declared inside another structure
prototype?
21
32
36
60
3
What is the structure tag which has date as a data member?
date
him
student
her
4
Which line is a student structure instance declared
(created)?
17
30
25
55
5
Which line is a student structure...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct game_piece
{
};
struct game_board
{
};
void game_piece_init_default(struct game_piece* piece)
{
}
void game_piece_init(struct game_piece* piece, char*
new_label)
{
}
char* game_piece_get_label(struct game_piece* piece)
{
return "";
}
char* game_piece_to_string(struct game_piece* piece)
{
return "";
}
void game_board_init(struct game_board* game_board, int rows,
int cols)
{
}
int game_board_is_space_valid(struct game_board* game_board, int
row, int
col)
{
return 0;
}
int game_board_add_piece(struct game_board* game_board, struct
game_piece*
piece, int row, int col)
{
return 0;...
In this activity, you will complete the RSS Client that connects to a UNL RSS feed, processes the XML data and outputs the results to the standard output. Most of the client has been completed for you. You just Lab Handout: Structures 4 need to complete the design and implementation of a C structure that models the essential parts of an RSS item. Your structure will need to support an RSS item’s title, link, description, and publication date. As a...
Help C++ Write a string class. To avoid conflicts with other similarly named classes, we will call our version MyString. This object is designed to make working with sequences of characters a little more convenient and less error-prone than handling raw c-strings, (although it will be implemented as a c-string behind the scenes). The MyString class will handle constructing strings, reading/printing, and accessing characters. In addition, the MyString object will have the ability to make a full deep-copy of itself...