C++ :: Allow User To Enter A String And Output In All Uppercase Letters

Oct 24, 2014

/* Program is to let the user enter a string and will output the sting in all uppercase letters. */

#include <cctype>
#include <iostream>
#include <string>

using namespace std;
char str1[80];

[Code] ....

I am trying to get the cin.get working where the user is allowed to enter an 80 character string and how to do that.

View 1 Replies


ADVERTISEMENT

C :: Converting A String Array Into Uppercase Letters From File

Apr 19, 2013

I am new to coding Here is the problem. Have a program prompt the user for a filename to open. Change every alphabetic character in the file to a capital letter. Numbers and special characters should not be changed. Print the output to the screen.

Here is my code so far but i am only returning the last line of text capitalized from the file. I am trying to get the program to display all of the three lines of text from the file capitalized. The program displays the file correctly before i try and convert everything toupper();

Code:

Code: #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
int main()
{
char line[81], filename[21];
int i;
FILE *inFile;

[Code]...

View 6 Replies View Related

C/C++ :: Function That Generates A Random String Of Uppercase Letters

Apr 19, 2014

I need to write a C function that generates a random character array (i.e. string) of uppercase letters - getchar and putchar are the only IO functions that I can use. Below is what I have already - I am iterating for as many times as I am required to, and am modulating rand() by 25, (total letters in the alphabet). I'm trying to see how to get the random letter from the % 25, and also how to do this without toupper() [not sure if I can use that function].

void getRandomStr()){
char str[40];
for (int i = 0; i < 40; i++){
char c = rand() % 25);
str[i] = toupper(c);
}}

View 5 Replies View Related

Visual C++ :: Convert String Of Uppercase Letters Into Its Corresponding Lowercase

Apr 26, 2014

Write A Program which converts a string of uppercase letters into its corresponding lowercase.Using pointers to access the members of the Array.

Write A program that reads eight float numbers into an array and then print out the second,fourth,sixth and eight members of the array,

And Sum of the first,third,fifth,and seventh. Using pointers to access the members of the array.

View 2 Replies View Related

C/C++ :: Input Lowercase String / Output Uppercase String

Dec 3, 2014

write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character array to store the string.) Does this follow the criteria? This program is very similar to one I found on these forums but I have one problem, it outputs everything backwards! EX: dogs will output to SGOD. What I need to do to make it output correctly, I think it may have to do with getline?

#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
int main() {
char let[100];
cout << "Enter what you would like to be UPPERCASE: ";

[Code] ....

View 2 Replies View Related

C :: Detecting Number Of Uppercase Letters?

Mar 20, 2014

Just wrote this extremely simple program but it seems to be malfunctioning. It counts correctly the number of uppercase letters in a string so long as i don't use the space-bar. once I add a space it only counts the number of uppercase letters of the first word..

printf("I ..........ing love programming");

Code:

#include <stdio.h>
main()
{
char text[200];
int i = 0;
int uppercase = 0;
printf("Enter text:");
scanf("%s", text);

[code]....

View 6 Replies View Related

C/C++ :: Uppercase And Lowercase Letters Count From File

Nov 11, 2014

char ch;
int uppercase=0;
int lowercase=0;
file.open(pav.c_str());
while(!file.eof()) {

[Code] .....

So I need to count uppercase and lowercase letters from file, and I always get 0. What is the problem with this part of code?

View 10 Replies View Related

C++ :: Number Of Characters / Operators / Uppercase Letters And Numerical Digits

May 5, 2014

I have to code a simple program who determining the number of Characters (A character could be any alphabets, digits, punctuation marks, or special , Operators ( Operators are those symbols that are used in mathematica expression, such as,'+', '*', '/', '-', and so on.), Uppercase letters (Uppercase characters are those from A..Z) and Numerical digits ( A digit is any of the Hindu-Arabic numerals from 0..9). Why the output is wrong!

#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std ;
int main() {
char text;

[Code] .....

This is my input file This is a possible factorial function in a programming language called LISP

(defun factorial (n)
(if (< n 2)
1
(* n (factorial (1- n)))))

This is my output:

The number of characters = 113
The number of operators = 3
The number of numerical digits = 3
Uppercase letters = 5

I think that "characters" is wrong, but I do not know why !

View 4 Replies View Related

Visual C++ :: Allow User To Enter A Value As C String In Certain Form

Oct 14, 2013

My program was to allow the user to enter a value as a C string in the form: xxx,xxx,xxx,xxx,xxx.xx, where x can be any digit. Well, so far here is my attempt. I think the question is, would I have to implement a switch statement for the digits, the comma, and the decimal, so that when a user inputs, let say 52,000.00 the switch statements would read the 1st digit, checks for decimals/commas and if not, proceed to read 2nd digit, and repeat?

Code:
#include <iostream>
#include <string>
int main() {
using namespace std;
char buffer[256];
char tempBuff[256] = {'

[Code] ....

View 3 Replies View Related

C++ :: C Type Strings - Program To Ask User To Enter A String And Perform Functions

Oct 18, 2014

My assignment is : Please use C type strings ( array representation of strings). Write a program that will ask the user to enter a string. It will then regard that string as a worked-on string and allow the user to perform the following editing functions on it:

s – search
i – insert
a – append
d – delete
a – append
d – delete
r – replace
e – exit
s – search

This option will allow the user to search for a specified string in the worked-on string. If the string is

found, it will display the starting index (position) of the searched string in the worked-on string.

here is what i have so far.

#include <iostream>
#include <cstring>
using namespace std;
int main() {
char a_string[80];

[Code] .....

View 4 Replies View Related

C :: How To Terminate A Loop If User Inputs Blank Space In A String Or Press Enter

Jan 28, 2015

Code:

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
int main(void) {
int i;
char *str;
int len = 1;

[Code]...

View 3 Replies View Related

C++ :: Converting User Input Int To String Output?

Apr 22, 2014

I am writing a code in a class that will change the user input which is integer to a string. For example if the user enter 13347..the output should change to "one three three four seven" on the user screen.I'm not getting the right output.

Code below:

#include <iostream>
#include <string>
using namespace std;
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
class convertTo{
public:
int signed num;
int convet(){
cout<<"Enter a number to convert to string "; cin>>num;

[code]....

View 2 Replies View Related

C :: Make First Letter Of Each Word In User Input Text Uppercase

Sep 22, 2013

I need to write a C program to make the user input some text,and the first letter of each word has to be uppercase.(have to use while loops)So for example lets say the user inputs:

i lOvE pRoGrAmMiNg
The output needs to be:
I Love Programming

Code:

#include <stdio.h>
int main()
{
int i = 0;
char c, lower_c;

printf("Enter text
");

[code]....

I have started this code by making the letters lowercase.I am not sure how proceed after this step, the step of making the first letter uppercase.

View 2 Replies View Related

C/C++ :: How To Uppercase All Characters Of A String

Oct 28, 2014

I'm working on a programming challenge and i need to uppercase all characters of the string.

string upperCaseIt(string& name){
for(int index = 0; index < name.length(); index++){
name[index] = toupper(name[index]);
return name;
}
}

My problem is that it only uppercase the first character of the string.

View 2 Replies View Related

C/C++ :: Uppercase String To Lowercase?

Dec 4, 2014

I have a function that converts an integer to Roman numeral and i've been searching everywhere trying to find out how to convert an uppercase string to lower case but I haven't found a good answer anywhere.

#include "stdafx.h"
#include <iostream>
#include <string>

[Code].....

View 1 Replies View Related

C++ :: How To Loop Through A String And Uppercase Each Letter

Apr 28, 2013

tell me how to loop through a string and uppercase each letter?

View 1 Replies View Related

C++ :: How To Print String In Uppercase Format

Feb 17, 2012

I have a problem. I need to print the string called "last" in uppercase format. can you check why my program prints nothing.

Here is the important section of the code.

if (infile.is_open()) // if file was able to open {
string line;
while (getline(infile, line)) {
string::size_type pos1 = line.find(' '); //pos1 is the position of the first space

[Code] ....

View 1 Replies View Related

C++ :: Convert Full Word To Uppercase If It Is Lowercase In A String?

Feb 28, 2014

The problem I am facing is that I have to output the C++ input file and display every line of code in the output, except in the output I have to convert every if, else, and while as IF, ELSE, WHILE. I tackled the first part and now its onto the 'easier' part even t

View 1 Replies View Related

C++ :: How To Prompt User To Input Only Letters

May 12, 2014

I am trying to write a program to get user's input but only accepts alphabetic characters, nothing else and I want it to ask the user to enter a valid word until they have finally entered a valid one. I have the following code for it but it does not work properly.

void CheckBound (char word1[], int SIZE1) {
int i;
int w1[SIZE4]= {0};
int found;
for (i=0;i<strlen(word1);i++) {

[Code] .....

View 2 Replies View Related

C++ :: How To Prompt User Input Only Letters (a-z)

Mar 1, 2013

How do I have the user enter only letters?

#include <iostream>
#include <limits>
int getInt() {
int x = 0;
while(!(cin >> x))

[Code] ....

But this function prompts the user to only input integer values. I was thinking if I could maybe try tweaking with this one so that the user could only enter letters..no luck though. So how can I have the user input letters only?

View 3 Replies View Related

C++ :: Truth Table Generator - If User Enters String Of Boolean Algebra It Will Output Table

Jan 25, 2013

If a user enters a string of boolean algebra it will ouput the table.

I have input parsing, cycling through the combinations, and outputing working. However once i parse the input I am not sure what to do with it. I have thought of having it write the parsed input to a new file as a function and then use that function, but that seems bad.

How to dynamically create the function, how to implement it.

BTW This is a console function, if that changes anything.

View 2 Replies View Related

C++ :: Enter Name Then Output Name In Vertical Position Using For Loop

Feb 21, 2013

How to fix this when i run the program and enter my name then output my name in vertical position using the for loop and press enter the program do not stop

#include<stdio.h>
#include<conio.h>
#include<dos.h>
main() {
char name,n;
clrscr();
printf("Enter Your Name:");
scanf("%c",&name);

[Code] ....

View 3 Replies View Related

C :: Program That Counts Letters Of 3 Lines Of Input From User

May 26, 2013

So I am writing a program that counts the letters of 3 lines of input from the user. I am using a 3 x 80 character array as the "notepad". Upper and lower case characters are incremented on the same counter array.

Code:

/*Letters in a string*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void countAlphabet(char *);
/*Character counting array*/
int alphabet[26] = {0};

[Code]...

View 3 Replies View Related

C++ :: How To Error Check If User Input Is Letters And Not Numbers

Jun 9, 2014

How do I error check if the user is inputting letters and not numbers? For example, if the user inputs "Lab.txt" I need to display an error message. If they input "Lab2part2.txt" then this is correct and what I want.

I've found a lot of information online on how to error check for numbers or a single letter (EX: 1,2,3, etc. or 'A' 'B' 'C') but nothing for actual WORDS or maybe I should refer to it as a string of characters?

Is there any way to do this? Because my program requires I ask the user to input the name of the file. But the way my code is currently set up is even when the user inputs the wrong file name it still opens the file. I want to prevent this from happening so my thought was to error check user input.

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void OpenTheFile() {
ifstream inputFile;
string filename;
char letter;
int number;

[Code] .....

View 1 Replies View Related

C++ :: Program To Stay Open Until Press Enter Even After Whole Output

Oct 10, 2013

My program closes after the out even though i've used cin.get():

I want the program to stay open at least until you press enter, even after the whole output.

Code:
#include <iostream>#include <string>
int main()
{
std::cout << "Please enter your name";
std::string name;
std::cin>> name;
// build the message that we intend to write

[Code] .....

View 4 Replies View Related

C++ :: Reads User Input And Arrange Letters In Ascending Order?

Apr 21, 2014

I am trying to build a c++ that reads user input and arrange letters in ascending order.

for example, if the user input: Hello my name is Moe! the output will be: !aeeehillmmmnoos (ascending order)

my problem is that when i input hello my name is moe the output will be ehllo (not completing other letters) also when i change class size to 50, it outputs unknown weird letters.

This is my code:

#define CLASS_SIZE 10
#include <stdio.h>
#include <iostream>
void bubbleSortAWriteToB(const char a[], char b[]);
using namespace std;
int main(void){
int i;

[Code]...

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved