SlideShare a Scribd company logo
1 of 6
Download to read offline
C++- Help with the section for doEditTweet only. NOT using strcpy, using snprintf to copy
string.
// Program to implement a very simplified list of tweets
// from a single simulated Twitter account
// Tweets can be added, deleted, and liked
#include <iostream>
using namespace std;
const int MSGSIZE = 100; // Maximum size for a tweet message
const int CAPACITY = 10; // Maximum number of tweets
// Structure used to define a tweet entry
struct Tweet
{
int id;
char msg[MSGSIZE];
int likes;
};
/*
* Prints out an entire timeline to the screen
* timeline = timeline of tweets to be printed
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
*/
void displayTimeline(const Tweet timeline[], int usedSize, int selected);
/*
* Edits currently selected tweet
* with a new message entered by the user.
* timeline = timeline in which the tweet is to be edited
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
* If 'selected' represents a valid array position, the
* selected tweet will be updated.
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doEditTweet(Tweet timeline[], int usedSize, int selected);
/*
* Adds a like to the currently selected tweet.
* timeline = timeline in which the tweet is to be edited
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
* If 'selected' represents a valid array position, the
* selected tweet will be updated.
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doLikeTweet(Tweet timeline[], int usedSize, int selected);
/*
* Deleted currently selected tweet.
* timeline = timeline in from which the entry is to be deleted
* usedSize = number of tweets in the timeline
* If 'selected' represents a valid array position:
* the selected tweet will be deleted
* usedSize will be updated to reflect the updated number of tweets in the timeline
* selected will be updated to -1
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected);
/*
* If there is room in the timeline for new tweets, then this gets
* a new tweet from the user and adds it to the timeline.
* timeline = timeline in which the tweet is to be added
* usedSize = number of tweets in the timeline
* If tweet was able to be added, returns the position number in the
* timeline of where the item was added, and usedSize will be
* updated to reflect the number of tweets now in the timeline.
* If tweet was not able to be added, returns -1, and usedSize
* remains unchanged.
*/
int doAddTweet(Tweet timeline[], int& usedSize);
/*
* Adds a new tweet to the list
* timeline = timeline in which the entry is to be added
* usedSize = number of tweets in the timeline
* message = tweet message to be added
* If tweet was able to be added, returns the position number in the
* timeline of where the item was added, and usedSize will be
* updated to reflect the number of tweets now in the timeline.
* If tweet was not able to be added, returns -1, and usedSize
* remains unchanged.
*/
int addTweet(Tweet timeline[], int& usedSize, const char message[]);
/*
* Returns the next available ID number
* timeline = timeline in which to find the highest ID
* usedSize = number of tweets in the timeline
* If timeline is empty, returns 100;
* otherwise, returns 1 + highest ID number in the timeline
*/
int getNextId(Tweet timeline[], int usedSize);
/*
* Gets a tweet id from the user. Searches a timeline to try
* to find the specified tweet by its id.
* timeline = timeline to be searched
* usedSize = number of tweets in the timeline
* If the tweet is found, the position number of where the tweet
* is stored in the timeline will be returned. If the tweet is
* not found, a 'not found message' will be printed, and
* the value -1 will be returned.
* If timeline is empty, an 'empty' message will be printed, and
* the value -1 will be returned.
*/
int selectTweet(const Tweet timeline[], int usedSize);
int main()
{
Tweet timeline[CAPACITY]; // Twitter timeline
int choice; // User's menu choice
int usedSize = 0; // Num of tweets in the timeline
int selected = -1; // Currently selected tweet
int tmp; // Temporary variable
// Add some starter entries for testing purposes
selected = addTweet(timeline, usedSize, "Where do they get the seeds to plant seedless
watermelons?");
selected = addTweet(timeline, usedSize, "Waffles are just pancakes with convenient boxes to hold
your syrup.");
selected = addTweet(timeline, usedSize, "Last night I even struck up a conversation with a spider.
Turns out he's a web designer.");
do
{
cout << "1. Display Timelinen";
cout << "2. Select Tweetn";
cout << "3. Add New Tweetn";
cout << "4. Edit Selected Tweetn";
cout << "5. Like Selected Tweetn";
cout << "6. Delete Tweetn";
cout << "7. Exitn";
cout << endl;
cout << "Select: ";
// Get the numeric entry from the menu
cin >> choice;
// Corrects issues where user might enter a non-integer value
while (cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), 'n');
cout << "Select: ";
cin >> choice;
}
// Makes the 'enter' key that was pressed after the numeric entry be ignored
// Should be used after getting any numeric input from the keyboard
cin.ignore();
switch (choice)
{
case 1:
displayTimeline(timeline, usedSize, selected);
break;
case 2:
tmp = selectTweet(timeline, usedSize);
// if selected tweet exists, update selected variable;
// otherwise leave it unchanged
if (tmp > -1)
selected = tmp;
break;
case 3:
tmp = doAddTweet(timeline, usedSize);
// if tweet was added, make it be the selected tweet;
// otherwise leave it unchanged
if (tmp > -1)
selected = tmp;
break;
case 4:
doEditTweet(timeline, usedSize, selected);
break;
case 5:
doLikeTweet(timeline, usedSize, selected);
break;
case 6:
doDeleteTweet(timeline, usedSize, selected);
break;
}
} while (choice != 7);
return 0;
}
int doAddTweet(Tweet timeline[], int& usedSize)
{
// TODO: Write code for the function
return -1;
}
void doEditTweet(Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
void doLikeTweet(Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
void displayTimeline(const Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
int addTweet(Tweet timeline[], int& usedSize, const char message[])
{
// TODO: Write code for the function
return -1;
}
int getNextId(Tweet timeline[], int usedSize)
{
// TODO: Write code for the function
return 100;
}
void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected)
{
if (selected == -1)
{
cout << "no tweet is selected" << endl;
}
else
{
selected = -1;
usedSize = usedSize - 1;
}
}
int selectTweet(const Tweet timeline[], int usedSize)
{
return -1;
}

More Related Content

More from jaipur2

Business inventories increased 19 billion in the second qua.pdf
Business inventories increased 19 billion in the second qua.pdfBusiness inventories increased 19 billion in the second qua.pdf
Business inventories increased 19 billion in the second qua.pdfjaipur2
 
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfjaipur2
 
BU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdfBU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdfjaipur2
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdfjaipur2
 
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdfBu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdfjaipur2
 
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdfBu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdfjaipur2
 
Bullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdfBullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdfjaipur2
 
Bulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdfBulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdfjaipur2
 
Bullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdfBullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdfjaipur2
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdfjaipur2
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfjaipur2
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfjaipur2
 
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++  Programming Exercise 9 from Chapter 16 Upload your so.pdfC++  Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdfjaipur2
 
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdfBU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdfjaipur2
 
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdfC Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdfjaipur2
 
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdfBu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdfjaipur2
 
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdfC problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdfjaipur2
 
C Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdfC Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdfjaipur2
 
c Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdfc Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdfjaipur2
 

More from jaipur2 (20)

Business inventories increased 19 billion in the second qua.pdf
Business inventories increased 19 billion in the second qua.pdfBusiness inventories increased 19 billion in the second qua.pdf
Business inventories increased 19 billion in the second qua.pdf
 
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
 
BU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdfBU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdf
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
 
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdfBu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
 
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdfBu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
 
Bullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdfBullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdf
 
Bulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdfBulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdf
 
Bullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdfBullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdf
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdf
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdf
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdf
 
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++  Programming Exercise 9 from Chapter 16 Upload your so.pdfC++  Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
 
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdfBU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
 
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdfC Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
 
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdfBu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
 
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdfC problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
 
C Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdfC Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdf
 
c Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdfc Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdf
 

Recently uploaded

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

C++ Help with the section for doEditTweet only NOT using s.pdf

  • 1. C++- Help with the section for doEditTweet only. NOT using strcpy, using snprintf to copy string. // Program to implement a very simplified list of tweets // from a single simulated Twitter account // Tweets can be added, deleted, and liked #include <iostream> using namespace std; const int MSGSIZE = 100; // Maximum size for a tweet message const int CAPACITY = 10; // Maximum number of tweets // Structure used to define a tweet entry struct Tweet { int id; char msg[MSGSIZE]; int likes; }; /* * Prints out an entire timeline to the screen * timeline = timeline of tweets to be printed * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet */ void displayTimeline(const Tweet timeline[], int usedSize, int selected); /* * Edits currently selected tweet * with a new message entered by the user. * timeline = timeline in which the tweet is to be edited * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet * If 'selected' represents a valid array position, the * selected tweet will be updated. * If 'selected' is not valid a 'no tweet is selected message' will be * displayed and no changes will be made. */ void doEditTweet(Tweet timeline[], int usedSize, int selected); /* * Adds a like to the currently selected tweet. * timeline = timeline in which the tweet is to be edited * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet * If 'selected' represents a valid array position, the * selected tweet will be updated. * If 'selected' is not valid a 'no tweet is selected message' will be
  • 2. * displayed and no changes will be made. */ void doLikeTweet(Tweet timeline[], int usedSize, int selected); /* * Deleted currently selected tweet. * timeline = timeline in from which the entry is to be deleted * usedSize = number of tweets in the timeline * If 'selected' represents a valid array position: * the selected tweet will be deleted * usedSize will be updated to reflect the updated number of tweets in the timeline * selected will be updated to -1 * If 'selected' is not valid a 'no tweet is selected message' will be * displayed and no changes will be made. */ void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected); /* * If there is room in the timeline for new tweets, then this gets * a new tweet from the user and adds it to the timeline. * timeline = timeline in which the tweet is to be added * usedSize = number of tweets in the timeline * If tweet was able to be added, returns the position number in the * timeline of where the item was added, and usedSize will be * updated to reflect the number of tweets now in the timeline. * If tweet was not able to be added, returns -1, and usedSize * remains unchanged. */ int doAddTweet(Tweet timeline[], int& usedSize); /* * Adds a new tweet to the list * timeline = timeline in which the entry is to be added * usedSize = number of tweets in the timeline * message = tweet message to be added * If tweet was able to be added, returns the position number in the * timeline of where the item was added, and usedSize will be * updated to reflect the number of tweets now in the timeline. * If tweet was not able to be added, returns -1, and usedSize * remains unchanged. */ int addTweet(Tweet timeline[], int& usedSize, const char message[]); /* * Returns the next available ID number * timeline = timeline in which to find the highest ID * usedSize = number of tweets in the timeline * If timeline is empty, returns 100;
  • 3. * otherwise, returns 1 + highest ID number in the timeline */ int getNextId(Tweet timeline[], int usedSize); /* * Gets a tweet id from the user. Searches a timeline to try * to find the specified tweet by its id. * timeline = timeline to be searched * usedSize = number of tweets in the timeline * If the tweet is found, the position number of where the tweet * is stored in the timeline will be returned. If the tweet is * not found, a 'not found message' will be printed, and * the value -1 will be returned. * If timeline is empty, an 'empty' message will be printed, and * the value -1 will be returned. */ int selectTweet(const Tweet timeline[], int usedSize); int main() { Tweet timeline[CAPACITY]; // Twitter timeline int choice; // User's menu choice int usedSize = 0; // Num of tweets in the timeline int selected = -1; // Currently selected tweet int tmp; // Temporary variable // Add some starter entries for testing purposes selected = addTweet(timeline, usedSize, "Where do they get the seeds to plant seedless watermelons?"); selected = addTweet(timeline, usedSize, "Waffles are just pancakes with convenient boxes to hold your syrup."); selected = addTweet(timeline, usedSize, "Last night I even struck up a conversation with a spider. Turns out he's a web designer."); do { cout << "1. Display Timelinen"; cout << "2. Select Tweetn"; cout << "3. Add New Tweetn"; cout << "4. Edit Selected Tweetn"; cout << "5. Like Selected Tweetn"; cout << "6. Delete Tweetn"; cout << "7. Exitn"; cout << endl; cout << "Select: "; // Get the numeric entry from the menu cin >> choice;
  • 4. // Corrects issues where user might enter a non-integer value while (cin.fail()) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), 'n'); cout << "Select: "; cin >> choice; } // Makes the 'enter' key that was pressed after the numeric entry be ignored // Should be used after getting any numeric input from the keyboard cin.ignore(); switch (choice) { case 1: displayTimeline(timeline, usedSize, selected); break; case 2: tmp = selectTweet(timeline, usedSize); // if selected tweet exists, update selected variable; // otherwise leave it unchanged if (tmp > -1) selected = tmp; break; case 3: tmp = doAddTweet(timeline, usedSize); // if tweet was added, make it be the selected tweet; // otherwise leave it unchanged if (tmp > -1) selected = tmp; break; case 4: doEditTweet(timeline, usedSize, selected); break; case 5: doLikeTweet(timeline, usedSize, selected); break; case 6: doDeleteTweet(timeline, usedSize, selected); break; } } while (choice != 7); return 0;
  • 5. } int doAddTweet(Tweet timeline[], int& usedSize) { // TODO: Write code for the function return -1; } void doEditTweet(Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } void doLikeTweet(Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } void displayTimeline(const Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } int addTweet(Tweet timeline[], int& usedSize, const char message[]) { // TODO: Write code for the function return -1; } int getNextId(Tweet timeline[], int usedSize) { // TODO: Write code for the function return 100; } void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected) { if (selected == -1) { cout << "no tweet is selected" << endl; } else { selected = -1; usedSize = usedSize - 1; } }
  • 6. int selectTweet(const Tweet timeline[], int usedSize) { return -1; }