C/C++ :: Make Program To Print Out String

Nov 24, 2014

I'm trying to make a program in C where the user enters a string and it prints a word for example (name) in lowercase then the same word again but in capitals and lowercase like this (NnAaMmEe).

my code is below;

#include<stdio.h>
#include<ctype.h>
int main()

[Code].....

View 1 Replies


ADVERTISEMENT

C++ :: How To Make A Program That Print Out Factors Of Integer

Oct 26, 2013

I want to make a simple program that will print out the factors of an integer. My program right now only outputs "The prime factors of 221 are 221, 221, 221, 221"... Where it should be "The prime factors of 221 are 1, 13, 17, 221"

#include <cstdio>
int factorsOf(int x);
//function
int main() {
int x = 221;
printf("The factors of 221 are ");

[Code]...

View 3 Replies View Related

C++ ::  make Program That Can Type String Into Another Window?

Apr 26, 2013

I am trying to make a program that can type a string into another window. I have gotten it to the point that it can type the string, just not correctly. It will type random numbers and not the given string. The key event uses ASCII code for the arguments, and I don't see anything wrong with my numbers. Here is the code I have so far.

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

[Code].....

View 2 Replies View Related

C :: Program To Print The Length Of A String

Oct 20, 2013

Well what the title says, but I can't get it done. This is what I got

Code:
#include <stdio.h>#include <string.h>
int main(void)
{
char word;
int count;
printf("Enter a word.

[Code] ....

View 4 Replies View Related

C :: How To Print Out Output String For A Program In Reverse / Backwards

Feb 20, 2013

How to make it so an output for a program would print out the string in reverse/backwards? I was just curious on how to do this.

View 6 Replies View Related

C/C++ :: Program To Scan Number And String Then Print Them To A File

Mar 19, 2015

I wrote this program to scan a number and a string until EOF then print them to a file named "data.list". the problem is that the program duplicates last line of input in the output file. so for example if the input is :

1 test
2 dream
3 code

then output (in data.list file) would be:

1 test
2 dream
3 code
3 code

I also changed the program code so that it reads from data.list file. even here it duplicates last line!

so when program reads the info above saved in data.list it would be:

1 test
2 dream
3 code
3 code
3 code

here's the code for writing:

#include <stdio.h>
int main( void )
{
int num;
char str[80];
FILE *fPTR;
fPTR = fopen( "data.list", "w" ); // opens a file named "data.list", create if doesn't exist
while(!feof(stdin)) // loop until End-Of-File is pressed. Ctrl-Z in Windows, Ctrl-D in Unix, Linux, Mac OS X

[Code]...

and the one for reading from file:

#include <stdio.h>
#include <conio.h>
int main( void )
{
int num;
char str[80];
FILE *fPTR;

[Code]...

How do I fix this behavior??

View 3 Replies View Related

C :: How To Make 918 Print As 18

Aug 27, 2014

i am using turbo c++ my program is based on maths equations and my final answer is 918 or any 3 digit number only but i don't want 918 to print instead i want only 18 to print. this program gives different output for every different input so i can't just minus 900 from it and get 18. i just want that no matter what 3 digit number is the answer,i just get the 2nd and 3rd digits while printing it and not the first.

the final answer giving equation is:-
f=2914-1996
where f is my answer and its 918
but i want it to print as 18 not 918

View 1 Replies View Related

C/C++ :: Make Circular List And Print It

Apr 28, 2015

I have this program. I am trying to do this Circular List but i think something going wrong. The first of all is the list.The second is if my code for delete and select function are correct and the third i would like my program getting a "n" number of names and then make the circural list then print it and then when i select a number delete every node until give us the only one left.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10
#define NUM_PER_LINE 6
typedef struct node {
char name[SIZE];
struct node * next;

[Code] .....

View 1 Replies View Related

C++ :: Make Output Print Out To Screen In Reverse?

May 26, 2013

How can I make the output print out to the screen in reverse?

Code: #include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);

[Code].....

View 7 Replies View Related

C++ :: Read Data From File Then Make It Into Array Of Structures And Print Afterwards

May 13, 2012

I am trying to read from a data file that has input as :

12.0, 11, 123
14.0, 12.1, 3

And I want the program to read the data from the file and then make it into an array of structures and then print that array afterwards.

Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_INPUT 1000
int n =0;
int i = 0;
typedef struct {
double x[MAX_INPUT];

[Code] .....

The program when run gives the following output:

Ishtiaque-Mohammed-Khans-MacBook-Pro:Comp20005 IshtiaqueMKhan$ gcc -Wall -ansi -o ProjectB ProjectB.c
ProjectB.c: In function "main":
ProjectB.c:59: error: incompatible type for argument 1 of "print_array"

View 1 Replies View Related

C :: Declared A String Constant And Trying To Print Length Of String

Oct 9, 2014

In this code, i declared a string constant and trying to print the length of string. I know that if i write char a1[7] or char a1[] than it runs and give aggregate output, but in this case it is giving double length of string.

Code:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
}

[code]....

View 5 Replies View Related

C :: Make A String Out Of Part Of A String

Dec 9, 2013

I have a string that contains a various number of lines which are each separated by and so what I want to do is to put each line into a node in a linked list.The relevant sections in my code are as follows:

Code:

typedef struct line *Line;
struct line {
char *text;
int lineNum;
Line next;
}

[code]....

Code:

strncpy(curr->text, text[prevPos], subLength);

With this line, I was hoping to make curr->text a string that is length subLength and begins at position prevPos in the text string. Except text[prevPos] is treated as a single character and not a string that begins at that position.

View 8 Replies View Related

C++ :: How To Make 2 Array (x / Y) String

Jun 9, 2013

I want to make 2 array(x,y) string , when i do

string temp[8][8]

but

cout << temp[3][4] does not work ....

View 3 Replies View Related

C :: Print First Word Of The String

Apr 12, 2013

1. Create a variable named index and nitialize it to zero(0)
2. Prompt for and input a string value from thekeyboard. Store the string inthe string variable newstring[80].
3. While (newstring[index] does not equal ‘’).

i. Display the character at newstring[index] followed by a NL
ii. Increment index ====================================== ...

And this is what i have done so far and i dont know where I am wrong ...

Code:
#include<stdio.h>
int main()
{
int index = 0; //initialize index to zero since first elementin an array is numbered zero
char newstring[80];

[Code] ....

View 3 Replies View Related

C :: How To Print The String In Main

May 23, 2013

if you have something like this how can you print the string in main??

Code:

/#include <stdio.h>
#include <stdlib.h>
void myf(char *p)
{
p="balls";
}
int main()
{

[Code]...

View 2 Replies View Related

C :: Print Words Of A String

Dec 4, 2013

I want to print the words of a sentence, given as a string..But I have a problem with the end of the sentence, and cannot find the bug....

Code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char str[80]="This is a sentence";
int main(){
}

[code].....

View 7 Replies View Related

C++ :: How Sub String And Math Can Be Used To Make Logical Decisions

Dec 1, 2014

This is an example of how sub string and math can be used to make logical decisions without using if/elses or switches. It works because of this equation

(x + |x|)/x = 2 if x > 0 and = 2 if x < 0.

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
//declaration of variables

[Code] ....

View 1 Replies View Related

C :: Making A String Print In Reverse

Oct 15, 2013

Here's what I have to do: Using strcpy() pass it two strings of characters (such as a name like John Johnson) and copy the second string into the first, in reverse order, and print both. Write a main to exercise your function and to illustrate that the function is working properly.

View 4 Replies View Related

C :: Print String With Escape Characters

Mar 7, 2013

is there any function to print a string with all the escape characters in it?

For example, instead of printing:
This is a string.

It would print:
This is a string.

Or in Windows:
This is a string.

I know that you can debug the code to find the variable contents, but is there any way to accomplish this with some standard library function?

View 6 Replies View Related

C++ :: Longest String Does'n Print On Same Line

Aug 4, 2014

I try to learn string class, resolving some problem, but i have some dificulties.The is ok, but when i print the longest string it does'n print on the same line.I enter the number of string, after that i enter the first string until i introduced from keyboard "#" character. I enter the second string and so on.Look at these example :

For i = 3;

Text[0] : I learn class String#
Text[1] : I dont learn class String#
Text[2] : String#

It print me like that : Text[1] :

I dont learn class String More than that look at the next example :

For i = 3;

Text[0] : I learn class String#abcdef
Text[1] : I dont learn class String#
Text[2] : String#

You see that in the first sentence i have continue to introduce some characters after # character and look what is happened :

Text[1] : abcdef
I dont learn class String

#include<iostream>
#include<string>
using namespace std;
int main() {
string text[100], cuvant;
int i, j, m, lung = 0;
cout << "

[code]....

View 3 Replies View Related

C++ :: Store And Print String On Screen

Sep 20, 2013

Given this sentence as an input: "Hello my name and "John" (with its spaces and capital letters), print it on the screen .. NB the phrase must be entered from the keyboard all at once ... you can do this in C / C + +?

View 3 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 :: How To Make String Array From Strings In Text File

Mar 24, 2013

I want to make a string array from strings in a text file. Itry to do this but i couldn't do, where is my mistake?

Code:

#include <stdio.h>
#include <stdlib.h>
int main(){
char cumle[100],*c,*dene[50];
FILE *input;
input=fopen("input.txt","r");

[Code]...

View 1 Replies View Related

C :: Cycling Through Memory To Print String With And Without Function

Feb 10, 2014

Anyways, I have a problem where I'm trying to cycle through memory via pointers to print a string. Here is my code:

Code:

#include <stdio.h>
int main(void){
char word[]="hello there";

[Code]....

This seems to effectively portray what I want

How do I print a string using the same method for(;*pointer!='/0';pointer++) without a function?

View 2 Replies View Related

C++ :: Mapping Strings To Integers - How To Print String Zero

Dec 12, 2013

I'm very very new to maps and am really just trying to hash them out by myself.

If you're mapping strings to integers:

map <string, int> myMap;
myMap[ "zero" ] = 0;
myMap[ "one" ] = 1;

How do I print the string "zero", for instance, from myMap?

cout << myMap.at(0) << endl;

doesn't work. Nor does:

cout << static_cast<string>( myMap.at(0) ) << endl;

I need access to the string using the int and the int using the string. Or just direct access to one or the other. . . It's just confusing that they're technically mapped to one another but I can't really access either of them.

View 4 Replies View Related

C++ :: Turbo Code To Print String Through Installed Printer

Nov 10, 2013

C++ Code To Print String through Installed Printer. How to user Printer File Name?

View 9 Replies View Related







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