I have been working on this program that reads an input file, then reads it, prints its averages and min and max, then writes a new file which organizes the names alphabetically and gives them a grade. I could assume the grade print in the new file could be easy enough with if statements, but I am stuck on how to get the names organized and print them by first name.
I am trying to alphabetize 3 different strings by comparing the first letter in each one. It will work for the first two names, but when I try to print out the third, I keep getting errors and I don't know why?
Code: #include <stdio.h> char personName(); int main() {
The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.
Code:
#include <stdio.h> int main(void) { int x, polynomial; }
I am trying to write a program that can communicate over a very latent internet connection involving a cellular modem. I have some software packages that handle all the telnet like business and will pipe stdout and stdin to a program I can have it execute.
The problem I am running into is that I have to send about 900 ASCII commands to an instrument to request data but it takes about a second between when a command goes out and when a reply comes back. This will wind up taking a very long time and I am looking to speed it up. All of the commands are independent of the reply so what I need to do is create a program that can send all 900 commands with maybe 10ms break between them and to not wait for a reply. It then needs to read the replies and write them straight to a file.
It seems like this should be achievable in C++ but I only have a very basic understanding of the language and thus am not sure where to start.
I am open to using other languages but thought C++ would be a reasonably good start so I can distribute the program to my coworkers. All of our work machines are Windows but if there is a simpler solution from Linux, I should be able to work something out. I'm just trying to avoid complication.
I am making a program which is going to print out a head image according to the input values entered by the user. Here is the code:
Code: #include <iostream> #include <string> using namespace std; void Sides() // draws the sides to take proportion
[Code] .....
At first i tried to work program like:
Code: cout << "plase enter which way you want to print out the head, with parted hair or bald." << endl; cin >> headstyle; if (headstyle != "bald" || headstyle != "parted hair" )
But it also had given the same mistake. The program compiles BUT; even if I put in the values bald or parted hair the program prints out "wrong input" then exits.
I'm working on a project that requires to make modifications to certain functions. So, I'll copy and paste the function to a new source code so I'm just working on the function with the entire program running. When I run the function by itself, it works fine. But when I copy and paste the function back to it's spot, the program doesn't wait for input at the cin.getline & it did wait when I ran just the function by itself. I'm using Dev C++ if that makes a difference.
I am not a programmer, C-wise. Mainly a shell scripter. any C program that I can use that can work like UNIX strings | grep "pattern"...At the moment, on a binary file, I am using UNIX strings and then grep for a pattern and print out that line and does some awk -F":" thing. This is manageable for when the binary file is 50M but not for where files are 100M and above. I mean it still works but takes longer since strings work on the entire file.
Basically the information that I am trying to extract from the binary file is some type of header that is contained in a file. I am thinking of maybe writing a 'simple' C program that will read the first few bytes of the binary file and then print the line that contains the string that I am looking for. I don't believe the header is at the end of the file but more in the beginning. I am wanting to extract the header information to be able to rename or make a copy of the binary in a more user-friendly name.
Any good reference/link to a sample program on reading a binary file maybe. Main reason why I am wanting a C program is because the binary file can be on Windows or *nix.
My objectives for this program is to open and read a file "dict.txt" which has the following data:
4 dog pepper marker teapot
It needs to rotate the inner letters one to the right so you'd end up with "mrkear" etc, and then write those words into a new file "scramble.txt" one per line.I'm having a lot of problems understanding the program. Compiling is giving me a lot of warnings/errors.
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXW 10 //max number of words in file #define MAXS 81 //max size of string }
I know there is a function for comparing string but i am making it to just improve my concepts.error : 2 is coming as answer when i put same sting in both place.
Write a program that reads several strings from a file. Display the number of words then display each word as shown in the sample below. Assume that the maximum number of string in the file is 100.
Sample Input (.in): Smitty Werbenjagermanjensen. He was number 1!
Sample Output:
Total Number of Words: 6
Word[0] = Smitty Word[1] = Werbenjagermanjensen. Word[2] = He Word[3] = was Word[4] = number Word[5] = 1!
'Write a program to match the user input string with the contents of text files and give the result as to which files contain the input string. This has to be done by using finite automaton.' (Any language can be used) So basically, the user will input a string (in the command line or a gui) and "we must pass the text files to the DFA" (I'm double quoting this because it's precisely what my professor told) and then display those files which contain the string. The string can be hard-coded, ie,the user will get the output file that contains a specific string. ex: 'hello'. The problem is, I have never done any program on DFA so I'm at a loss. how to write the program. Should I read the files first and then use some 'switch' or 'goto' conditions for the DFA? Below is a code I found on the internet for simulating a DFA accepting a specific string.
Code:
s: accept = false; cin >> char; if char = "m" goto m; if char = EOF goto end; goto s; m: accept = false; cin >> char; if char = "m" goto m; if char = "a" goto a; if char = EOF goto end; goto s; }
I'm working on a program that provides a number of utilities for strings, but I keep getting segmentation faults and I cannot tell why. strContains works fine, but basically the rest of my functions throw seg faults.
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];
I am programming a translator, and I have it so that it detects words with spaces both in front of and behind them, so I did "string.append(space);" where space equals " ". That added a space to the end, but I still need a space added to the front.
I have a problem who must print the sentences who have lenght more than 20 characters. I dont know why, but it prints just the first words. Look what i made.
#include<stdio.h> #include<conio.h> int main()
[Code]....
For instance :
Give the number of sentences : 3
First sentence : I like the website bytes.com Second sentence : I like more the website bytes.com Third sentence : bytes.com
After I compile the program it should print the first two sentences.
I just dont see what the issue is here. I have stared at this thing forever. Im trying to make a calendar from scratch so I can be prepared for my second test on Friday.
Code: #include<stdio.h> #include<stdlib.h> int main(void) { int i, n, s;