Any way to do it...its only works with the first letter. So i have a txt file with information such as de3 dn5 dn7 dw9 ds1 and how to get the letters and then the number.
example:
if de print this is de; and print the number that follow de
Code:
#include <stdlib.h>
int main ()
{
FILE * pFile;
int c;
pFile=fopen ("de3.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
I'm working my way through some C exercises to get some practice and have hit a wall. I need to use a function to take a number, such as 1, and print out One.Here's what I've got so far:
Code: #include <stdio.h> int name(int n); char numberOne[] = "One"; int main(void) { int n; }
[code]...
However, when I run the code and enter "1" the only thing that gets printed to the screen is "(lldb)". I've tried changing it to doing it without variables and just printing "One" but that gave the exact same result.
I created a function to check whether the first character of a string is a number or not by comparing it to every base 10 digit using a for loop. If it is, the string is valid, if it is not, the string is not valid
Code: //ensure the first character is not a number int ValidFirstChar(char FirstChar) { int IsChar = TRUE, DigitCount = 0; /*boolean value indicating whether the first character is a number or not.*/
//check through all base 10 digits for (DigitCount = 0; DigitCount <= 9; DigitCount++) { if ((int)FirstChar == DigitCount)
[Code] ....
I have checked for the case where the first character is a number but it is displaying the error message for it. I have tried typecasting the char variable but that has not worked.
I've been struggling with this for a while, I have to write a function that accepts a word (in my case the word is "the") and file pointer, and counts the number of times the given word appears (case insensitive) within the file associated with the pointer. This means the two words "the" and "THE" should both be counted.
Here is my code:
int WordCount :: countWords(string wrd) { int counter=0; string temp = ""; while (getline(*file,temp)) { for (int i = 0; i < temp.length();i++) {
[Code] ....
This is what I have come up with, but I get an incorrect value. It was suggested to us to consider using the strcpy() or strstr() functions, but I don't know how to use them.
I have to write a function that accepts a word (in my case the word is "the") and file pointer, and counts the number of times the given word appears (case insensitive) within the file associated with the pointer. This means the two words "the" and "THE" should both be counted.
Here is my code:
int WordCount :: countWords(string wrd) { string temp; int counter; while (!file->eof()) { *file >> temp; if (temp == wrd)
Im programming a roguelike game using visual c++ Microsoft express 2010 and i made a multidimensional array for my first map. I have the walls as # and was wondering how i could turn those into ascii symbol 219. Also i need to know how to turn specific text certain colors.
I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:
You have 40 letters at $3.45 per letter, and your total is $138.00.
Everything compiles fine but when I run it the inputs don't work and it outputs:
You have -1 per letter, and your total cost is $-0.
Everytime I type a character, the number 1 appears in the next line. And i just keep getting the message "Wrong! I have more than that." even when I type a number bigger than 1023
Code:
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand(time(NULL));
The function uses a "for" loop to print the given character the number of times specified by the integer.
How can I make a for loop to do that?
So.. my code looks like this:
// cpp : Defines the entry point for the console application // #include "stdafx.h" #include <iostream> using namespace std; void printMyInteger(int myInteger, char myChar) {
[Code] ....
So.. here is my error:
Error1error C2143: syntax error : missing ';' before ')'d:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp101Week 6 Error2error C2143: syntax error : missing ';' before ')'d:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp101Week 6 3IntelliSense: expected an expressiond:workspaceuniversity ools for games and animationworkshopsweek 6week 6week 6week 6.cpp107Week 6
I have an assigment to make program which deletes from sentence all words with character count which is equal to pair number , for example - [ I like C ] and the result of this program should be [I C] because the word like contains 4 characters which is pair and it should be removed.
So I started writing my program and I am stuck at this block of code -
#include <stdio.h> #include <stdlib.h> main () { char text[100], blank[100]; int c=0,d=0,i,j; gets(text);
[Code] ....
To explain what is happening - I go through all string and search for first ' ' space symbol and check its value. If it is pair then my program prints that it is not pair[because last character before space had not pair number of characters], but the hardest part comes in when i have two not pair words , because space takes one character and now when i check if i%2 == 1 the answer is false [0] for the second word .
I'm trying to determine the number of times I have to change each specific character in a string to make it a palindrome. You can only change a character one at a time from the end.
Example: "abc" -> "abb" -> "aba" should print 2. "aba" will print 0 because it's already a palindrome. "abcd" -> "abcc" -> "abcb" -> "abca" -> "abba" will print 4 because it took 4 changes to make a palindrome.
I'm not too sure how to approach this - I figured out the case where if it's a palindrome (if reversed string is the same) then it'll print out a 0.
int main() { int number; cin >> number; //expecting a number for first line user input for (int i = 0; i < number; i++) { string str;
Basically I have a text file called words. I'm supposed to extract a word randomly form the file and have the user guess the word. If they guess the word correctly in x number of tries they will receive the definition.
I'm having trouble receiving that random word and I'm getting the definitions from the file.
This is what is in the words.txt file apple#the usually round, red or yellow, edible fruit of a small tree boat#a vessel for transport by water horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding television#a system for transmitting visual images and sound that are reproduced on screens soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc. bottle#a container, typically made of glass or plastic and with a narrow neck barber#a person who cuts hair toast#sliced bread browned on both sides by exposure to radiant heat radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects red#of a color at the end of the spectrum next to orange and opposite violet
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'm learning programming, and C++. I've got a question, but I couldn't solve my problem so far. I need to use arrays and only basic stuff to solve this:
Create a program that reads a word from the user and then print (cout) this word on contrary. It's simple, I know, but I can't do it,. I've tried some stuff but I don't get how I will get the proper values to do this. All I know is that I can use variable.lenght().
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main(){ char *oneword;
I have text (string) and I want to find a given word (it's ok!) and then insert another given word after the first word. The original string is beeing copied into a new string. But something is going wrong!!! Where is my mistake?
(I have some patches...)
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> //insert "new_word" after each occurence of "word" int main(){ char A[100]="In the sentence words the and the.";