I have a pre-declared array which sorts strings to it's alphabetic order and want to change it so it reads from stdin.
char *array[] = {"aaa", "ccc", "bbb", "ddd"}
I tried doing something like this:
for (i = 0; i < length; i++) scanf("%s", &array[i]);
I just can't bring it to work. Another thing is, the input is a a bunch of strings separated by commas and ends with a period. Since I have to make a working C model which gets translated to assembly language later on I can't use functions like strtok.
I am creating a student management system (using classes) for my assignment and am stuck with designing UI. I made the classes but am not sure what the best control is to display items from a Dictionary<> object. Right now I am using the ListView because of the columns in details view...just want to know if there is a better, simpler control I could use if i want to display data (without using sql)...or is the good old "next" and "previous" option the simplest?
I want to implement a lexicographical order of some characters entered from the keyboard. when i press "n" i want it to return the order. Ignore the part with "insert a specific number of words" that's for smthn else.
#include <iostream> #include <string.h> using namespace std; int main () { int n, i, j; char oprire, decizie, v[20], x[100][20];
[Code]...
it keeps giving me returned error code -1073741819
I'm trying to use a listview component to show all the fonts on my system, and display each item (row) in the actual font design.
When I run the following code, nothing displays in the listview.
If I rem out line 4, then the list populates with all the fonts, but of course, in the default listview font.
I thought I read somewhere that each item in a listview can be set to a different font.
int i = 0; foreach (FontFamily oneFontFamily in FontFamily.Families) { listView1.Items[i].Font = new Font(oneFontFamily, 10); listView1.Items.Add(oneFontFamily.Name); i++; }
I am trying to make a program with a Cartesian class that allows the user to enter 2 coordinates and displays these coordinates. When I try to compile it, I get a message saying the x and y in x=c and y=d don't name a type. How can I fix this? Also, how would I go about inserting an assignment function that assigns the values of coord1 to coord2?
Code: #include <iostream> #include <istream> #include <ostream> using namespace std; class Cartesian { private: double x; double y;
I need to have a program display an error message if the variable entered isn't an integer but then I want it to cin again. I have this but it doesn't work:
cout << "Enter an Integer: " ; for (;;) { cin >> var; if (!cin) {
[Code] ....
I am not sure how to do what I want and this doesn't work, it just repeats That wasn't an int.. over and over again.
This program I am trying to write has a structure of persons with a first name last name and age for each.
What I need it to do it display the order of the persons before sorting and then display the persons after sorting by age.
So far I have written the overall program but am stuck at the most important step...which is defining the functions that will be doing all of the work.
For sort_by_age I want use bubble sorting by writing the function myself and for print_person_info I am confused on how to print data out of the struct.
Code:
#include <stdio.h> struct person { char first_name[20]; char last_name[20]; int age; }; void print_person_info(struct person clone); void sort_by_age(int n, struct person a[]);
I am building a linked list and i need to display function i have. The display function displays all the letters of the word entered instead of the word itself. below is my struct, one of my functions and the display function.
I am working on a program where i prompt the user for his/her name and i have to verify that the name only contains alphabetic characters.
here is my coding. It works to an extent i just can't get it to work the way it is supposed to.
#include <iostream> #include <cstring> using namespace std; const int SIZE = 50; int main() { char name[SIZE]; cout << "What's your first name?" << endl;
[Code]...
when someone types in a name with only alphabetic characters it outputs valid name for how long the name is. For Ex: bob is three characters so it would output valid name three times. also when you put in a name with a number or character at the end it outputs valid name for the correct characters but also outputs the invalid character and invalid name which its supposed to do. the valid name should not be showing up though.
Q1. Recursive function that receives an integer x and prints the alternating alphabetic characters.
Write a main function to test the function;
ENTER NUMBER : 4
A C E G
Q2. Define a void function that finds the smallest value in the array and number of its occurrences. Also, it finds the largest value in the array and number of its occurrences.
ENTER 4 NUMBERS: 1 12 5 41 41
THE BIGGEST IS 41 AND IT OCCURS 2 TIME THE SMALLEST IS 1 AND IT OCCURS 1 TIME
The program should store a character array in reverse order then display the reversed array. I have also included in the code that will display the actual characters into the array as it loops through. So I know the characters are being stored, but why doesn't it display the entire string when I call it?
I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.
#include <iostream> using namespace std; int Max(int x); int main() { int x;
I just started on a project on c++ and I was wondering if it is possible to add a select option (where the c++ program requires the user to select an option) . I couldn't find this anywhere.
I've been having problems with my loop that asks if the user wishes to continue or not. The required input should either be 'y' or 'Y', or 'n' or 'N'. Anything else should be counted as invalid, and repeat the prompt for input. The first few times I ran my program, the compiler does not read it as a loop. The next few times just won't work properly.
Here is the prompt: Code: void question() { char option; printf(" Do you want to continue? {Y|N) "); scanf("%c", &option);
[Code] ......
As it is, it immediately runs the else option, but otherwise runs just fine. I suspect it could be because I have not specified a size for the option variable, but I try doing that, and the prompt relegates everything to the else.
(And also, here's the rest of the code. Basically, it just assigns a value to the letters of the word (a/A = 1, b/B = 2, etc.), adds these values, and determines if a word is prime or not based on the sum.)
Code: #include <stdio.h> #include <string.h> #define size 30 int main() { char letter, word[size], lower, upper, option; int i, value, ans = 0, a, choice = 1;
I have a menu for a project that takes a string input and does whatever option you specify. It works perfectly EXCEPT when it goes through the while-loop (while you didn't say quit the menu reloads). It will spew out all the text in the menu like a bulimic teenager. Then it reloads properly and asks you for an input like nothing happened. While this is not a fatal error (code still functions)...
So , i had to make an rock paper scissors game . After lot of hard work and struggle ,I completed it but my professor rejected it since I didnot add option where it says "Would you like to play again .Y/N " . The code has too many brackets ! Here is my code
#include <iostream> #include <ctime> #include <cstdlib> using namespace std;
// for displaying the outputs to the user; passing string to functions void user_win() {
Remove the break statements from each of the cases. What is the effect on the execution of the program? Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output.
Sample Run: What grade did you earn in Programming I ? A YOU PASSED! an A - excellent work!
Rewrite the program LastFirst_lab44.cpp using if and else if statements rather than a switch statement. Did you use a trailing else in your new version? If so, what did it correspond to in the original program with the switch statement?
// This program illustrates the use of the Switch statement. // The break statement causes all subsequent expressions to be executed as well, also known as "falling through". // The trailing else statement acts just like the default section if none of the options from before work it gets "defaulted" to it.
#include <iostream> using namespace std; int main() { char grade; cout << "What grade did you earn in Programming I ?" << endl;
[code]....
how do you add an additional switch statement? i tried multiple times and i'm not sure if i don't understand braces enough but it didnt seem doable. also, I'm not sure what the teacher wants me to submit.
I need to do a code that gave me Original string, uppercase string, lowercase string, reverse string (if letter is upper then convert to lower, and if lower then convert it to upper) and uppercase first (first character of each word in uppercase).
I need to do it in functions but i dont know hot to use strings. The program should provide the option to save the outputs in a file.
I am running ubuntu and have tried adding -1GL to the end of my gcc compiling commands but the error says "unrecognized commandline option: 1GL". do i have to install any packages to get this to work?