Your program will declare a 2-D array of dimensions 20 x 20. The array will be of type "character".
Functions: You will create several functions for this program.
1) One function will take the address of the array and initialize all cells to ' ' (a blank space).
If the 2-D array is odd, then you will create functions that make:
2) a triangle using '*', OR
3) a diamond using '*', OR
4) a bulls-eye using '*'. <=== this one is worth BONUS POINTS!! and is therefore optional.
If the 2-D array is even, then you will create functions that make:
5) checkerboard #1 using '*', OR
6) checkerboard #2 using '*', OR
7) a GIANT checkerboard using '*'. <=== this one is worth BONUS POINTS!! and therefore is optional.
These functions will be called from main, and return nothing. Your program will keep asking the user if they want a different kind of 2-D array and different shape. If not, then quit.
Here is what I have so far. I have only been able to get the triangle work. I have not attempted the bullseye or giant checkerboard as they are for extra credit and I can't get the main program to work.
#include <cstdlib>
#include <iostream>
void clear(char pattern[20][20]);
void triangle(char pattern[20][20], int size);
void diamond(char pattern[20][20], int size);
// void bullseye (char pattern[20][20], int size);
My question: -I have a file of fixed length chatracter records each 30 bytes long. -I want to read them into an array which is 30 (or 31, say to account for the record terminator) characters by 50. -Is there a simple (possibly elegant, even) way to do this. On my reading of the tutorials so far any method I can come up with seems a bit clunky - rather like the assembler language I used in the 1970s.
I'm given a .cpp file (for homework), this file populates an array from a file, that contains only numbers, using the standard method of populating an array but I'm supposed to modify it so that the array gets populated using a pointer, pretty simple right? Not so for me, I think I'm still confused on the concept of pointers. Here's what I have so far...
I have this program for class where we just need to show that we can read, write to a text and binary file. We also need to populate an array from both a text and binary file. When the user first runs the program, the user is told that text/binary file does not work for reading because they do not exist. The user is then asked to start inpuyting integers into the console and at the same time creating and appending to a text/binary file. These values are also stored into an array as they are being inputted. Later in the program the array is run through a for loop and displayed to the screen. Displaying the array to the screen works fine here.
My problem is when the user runs the program for a second time. The text file is opened and an fgets is run to populate an array based on the numbers in the text file. That array is then used again for the user input and file writing section of the program. When the array is displayed at the end of the program the numbers do not make sense. Some appear to be correct bu most do not. When I do the similar actions to the binary file there is no problems. The text file is amended properly everytime the user runs the program. userInputText[MAXSIZE]is a char array (MAXSIZE is defined at 100000) and both textCount and textCounter are initialized to zero when the program is at this point.
Here is what the code where I believe the program resides. I have also attached the source file.
But now I'm trying to use this to point to a function inside a class so instead of do11, i want to be able to point to Basic.Do11. Somehow this doesnt work and I keep on getting this message:
error: argument of type 'void (Basic::)()' does not match 'void (*)()'
I have a gridview, im using its 'datasource dropdownlist' to populate it, i have the SQL statement
SELECT Orders.ID, OrderDetails.ProductId, OrderDetails.ProductName, OrderDetails.Quantity, OrderDetails.Price, OrderDetails.Total FROM (OrderDetails INNER JOIN Orders ON OrderDetails.ID = Orders.ID) WHERE (Orders.CustomerId = ?)
where the '?' is parameters source = QueryString, and QueryStringField= email
i have a session that is the customerEmailId, so
string CustomerEmailID = (string)Session["email"]; Response.Redirect("MyAccount.aspx?email=" + CustomerEmailID);//i have tested it and customerEmailid is test however nothing loads in the GridView
I am trying to complete this program and as far as I am aware, the only thing not working correctly is populating the listview with my data. I've been stressing over this for a few days and achieving no success. I have to load data from two text files (incidents.txt and technicians.txt), then use a query to populate a listview with all incidents that have been closed. Also, I have to use LINQ for this assignment, so I cannot change anything that would alter my use of that. I'm thinking that perhaps the problem is with my code in form1.cs?Included are all my classes,txt files, etc.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IncidentsByTechnician {
[Code] ....
Incidents.txt
45|1089|LEAGD10 |12|7/9/2012|7/13/2012|Problem upgrading from League Scheduler 1.0|Program fails with error 303 when trying to install upgrade. 46|1016|TEAM10 |14|7/9/2012|7/12/2012|Unable to restore data from backup|Error 405 encountered while restoring backup: File not found. 47|1034|DRAFT10 |13|7/9/2012||Can't activate product|Product activation code invalid. 48|1049|TRNY20 |11|7/9/2012||Unable to print brackets|Program doesn't recognize printer.
Technicians.txt
11|Alison Diaz 12|Jason Lee 13|Andrew Wilson 14|Gunter Wendt 15|Gina Fiori
The scenario is that I have an XSD schema; I have generated a C# class using the XSD tool in the Visual studio command line.
I have then created a basic console app, which will populate the first partial class in the generated C# class.
The program will then serialize this data and create an XML in a folder as a proof of concept.
The issue I'm having is working out the best way to populate and serialize all the data from the class, as the XSD it was generated from is quite large.
I would like to be able to randomise the data at a later stage once I have the basic populating and serializing working.
I have a program I have been working on where the user selects a date and enters the number of days to be viewed in the Calendar.cshtml view. This input renders another view (Update.cshtml) that contains two date picker boxes, one that should contain the selected date and the second one that should contain the calculated date. I am having an issue getting the date selected in the first view to populate to the first date block on the second view as the default and getting the calculated date to populate the second date block in the Update.cshtml view. In addition given the two dates, I would like to generate a calendar, which is why I chose the date picker approach and setting static dates.
Here is my code:
**CalendarController:**
using System.Web.Mvc; using VanickCalendarApp.Models; using System; namespace VanickCalendarApp.Controllers { public class CalendarController : Controller {
What "int values" is supposed to mean as parameters to these functions? I'm not sure what do with them. Also how to input values into the array via functions. I was trying to but I just don't understand how to connect a user's input to a function to then enter into an array.
// input reads “values” integers from the user to place in the array data. It prompts the user for each value individually with the ordinal position of the value. void input (int data [size], int values); // Places the sum of corresponding values from arrays a and b and places the results in array s. The first “values” integers in the array are processed. void do_sums (int a [size], int b [size], int s [size], int values);
I keep getting an unresolved external symbol error in the double GetHighest function. Ive looked over the code many times and can figure out why its giving me this error.
//Question 1
// Copy source code below and save to a .cpp file (say lab11_01.cpp) and write statements to print what is indicated in the source code. //In this question, you will implement code for finding the highest value in an array, and you do this in a function. //This program gets a series of test scores and calculates and display the highest score.
#include <iostream> #include <iostream> #include <iomanip> using namespace std; // Function prototypes void getTestScores(double[], int); double getHighest(const double[], int);
I'm trying to create an array of function pointers and then assign compartilbe functions to them, so I can just call *pf[0](xxx);
The functions are all of the type
void func01(unsigned char*, int, int)
how would I create an array of function pointers and assign the address of the functions to them? So I could call them like
ptrToFunction[i](charBuffer, 10, 20);
I've read a bit on line and I thought I could do it but so far I've failed.
It seems trivial and I feel I'm close but close isn't good enough.
I'd like to assign the fuction addresses like this: for (int i=0; i<10; i++) if (i==1) ptrToFunction[i]=func01; if (i==2) ptrToFunction[i]=func02; etc.
The actual logic is somewhat different than this but this close.
I am trying to perform columnSum and rowSum, as well as twoDadd and twoDSubtract using the arrays defined in my driver. How would I do that using A and B in my driver?
I'm a little confused by my programming assignment this week. I've been working at it Wednesday and I've made progress but I'm still confused as to how I'm supposed to do this. The class I made is called Stack, and it's derived from a template class called StackADT. We also utilize a class called unorderedLinkedList, which is derived from a class called linkedList.
We're supposed to implement all of the virtual functions from stackADT in the Stack class. The Stack data is stored in a an unorderedLinkedList, so what I'm confused by is how to implement a few of the Stack functions because there are no functions in unorderedLinkedList which we could call to manipulate the data.
As you can see from my attached code, I'm really confused by how I'm supposed to implement the pop() and top() functions, and I also think my initializeList() function is wrong. We don't have any similar functions in unorderedLinkedList to call, so I'm at a loss of how i'd access my unorderedLinkedList. My initial thought was to call the similar functions in the class that unorderedLinkedList was derived from, linkedList, but I'm unsure of this is what we're supposed to do, or if theres actually a way to access my unorderedLinkedList without having to use the functions from the base class.
NOTE: We're not allowed to modify stackADT, unorderedLinkedList, and linkedList.
Stack.h
#include "stackADT.h" #include "unorderedLinkedList.h" template<class Type> class Stack: public stackADT<Type>{ template <class T> struct nodeType { T info; nodeType<T> *link;
How to capture incoming serial data and store it into an array for controlling functions. But I am now working with a radio module that receives incoming data and stores it into a uint_8t.
From there in the basic sketch that the radio library came with it is printed in the serial terminal like this:
uint8_t buf[RF22_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (rf22.waitAvailableTimeout(500)) { // Should be a message for us now if (rf22.recv(buf, &len)) { Serial.print("got reply: "); Serial.println((char*)buf);
I have read a lot of tutorials on pointers, and I am just having a very hard time grasping how to extract data out of one. I realize this is char and not integers. The goal is to transmit five integers in a digital state of either 1 or 0, and then store them in the receiving side and control 5 outputs based on the status of those 5 bits. This is proving to be quite confusing for me though as I cannot seem to grasp how to control the pointer logic.
So In my studying of C I am starting to come across more programs with functions in them.This particular program asks for two numbers, and calculates the sum of all the squares of the two numbers and the numbers in between them. I am confused about the get_int() function.
Code:
/* checking.c -- validating input */ #include <stdio.h> #include <stdbool.h> int get_int(void); // validate that input is an integer bool bad_limits(int begin, int end, int low, int high); // validate that range limits are valid double sum_squares(int a, int b); // calculate the sum of the squares of the integers a through b }
[code]....
So in that get_int() function, it's pretty simple if scanf returns 1, otherwise... another while loop call the getchar() function, which is assigned to the variable ch. So say I enter 'a' for the lower limit, this is what happens:
Code: Enter the limits (enter 0 for both limits to quit): lower limit: a
a is not an integer. It seems as if getchar() somehow "got the character" from scanf(). There's no way that getchar() could have been simultaneously reading my input, because that function is not even called until scanf has already not returned 1. So I'm confused how that happened. I was under the impression that getchar() got input from the keyboard, which would lead me to think that I would be prompted to input something again when getchar() is called, before putchar() prints the scanf input. But this is obviously not the case.
Also, I'm curious about that comment beside putchar(ch) that says //dispose of bad input. I recall a long time ago on these forums, someone told me something about how once scanf has read input, that input is like... stuck to scanf.. So does putchar() not only print the input from scanf/getchar, but also unload it from scanf, so to speak?
I'm getting a bit lost in calling functions correctly. The assignment says to, reprogram this assignment using functions and include the additional features identified below -
Design your program so the main function invokes/calls functions to perform the following tasks:
4) sort the arrays in ascending order by student ID number
Here's what I've got thus far and I'm confused cuz I might be calling my function incorrectly.
Code: #include <stdio.h> #define MAX_ENTRIES 50 void s_ID (int student_ID[], int test_score[], char char_val[]); int main (void) {
I am new to c and I have come across a problem when adding other functions to a programme and printing the values. The question I am attempting to solve is :
The following function computes ex by summing the Taylor series expansion to n terms. Write a program to print a table of ex using both this function and the exp() function from the math.h library, for x = 0 to 1 in steps of 0.1. The program should ask the user what value of n to use.
double taylor(double x, int n) { int i; double sum = 1.0; double term = 1.0; for (i=1; i<=n; i++) { /*Or we could have written: */ term = term * x / i; /* term *= x / i; */ sum = sum + term; /* sum += term; */ } return sum; }
My code is
Code:
#include<stdio.h> #include<stdlib.h> #include<math.h> /*Taylor series for e*/
[code]....
code prints out the values for exp, but it gets stuck in the Taylor function and I'm not sure how to solve it.
forget everything from before. It came out of confusion regard the supplier functions. dis_s() and read_s() the part functions work and are not any different really.
when I run the dis_s() function it just prints out garbage until it segments. starts with a bunch of 0 and newlines until it starts printing locations on my computer...... it worked on campus with debian and I only copied it from gmail to my computer so I really don't understand whats up(im on mint).
In my program below, in the getage and get level functions, if an incorrect input is entered, then the correct one is entered after, it still returns the bad input back to main.