C++ :: Program Doesn't Alphabetize Strings

Jan 18, 2015

I can't seem to get my program to alphabetize a vector string. It displays the names, but not in a sorted order.

void sort_names(vector<string> &nameList) {
int i, minIndex;
string minValue;
int size;
size = nameList.size();

[Code] ....

View 4 Replies


ADVERTISEMENT

C++ :: Alphabetize With Different Strings?

May 14, 2012

How would I alphabetize this with the different strings? Would I just need to use a bubble sort?

Code:
#include <iostream>
#include <string>
#include <fstream>

[Code]....

View 11 Replies View Related

C/C++ :: Read A File And Alphabetize?

Aug 29, 2014

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.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

[Code].....

View 10 Replies View Related

C++ :: Program Compiles But Doesn't Run

Apr 28, 2013

My program compiles but doesn't run, Here is the screen shot of debugging

//DynBag.cpp : Implementation File
#include <stdexcept>
#include <iostream>
#include "DynBag.h"

[Code] .....

View 3 Replies View Related

C :: Trying To Use Array Of Pointers To Alphabetize String

Dec 8, 2013

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() {

personName();
return 0;

[Code] ....

View 4 Replies View Related

C++ :: Program Doesn't Read The End Of File Sequence

Aug 16, 2014

i have a question, i'm studyng the string library type and i have to write this program :

Code:

std::string word;
while (std::cin >> word) {
std::cout << word << std::endl;
}
why if my input is :

hi my name is ^Z

the output is :

hi
my
name
is

why the program doesn't fall out from the while loop ?

why my program does not recognize my sequence of end of file ?

View 5 Replies View Related

C :: Program Doesn't Print Data From Socket

May 7, 2014

I created a basic socket server, which listensing for incoming udp data. When I run the netcat program, I get a response:

Code:
$ nc -luv 1732
Connection from 10.50.11.12 port 1732 [udp/*] accepted
(?@??8?? ??.?n?5
(?@??8?? ??.?n?5|?>)
(?@??8?? ??.?n?5|?>)
^C |?>)

But with my c program it doesn't give the response. It should say something like "here is the message: " and then give a message.

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>

[Code] .....

View 2 Replies View Related

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

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;
}

[code]...

View 5 Replies View Related

C++ :: Program Output That Doesn't Wait For Replies But Still Captures Them

Jul 21, 2013

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.

View 5 Replies View Related

C++ :: Program Only Accept Integer From 0-10 But Doesn't Show The Factorial

Feb 28, 2013

#include<iostream>
using namespace std;
int main() {
int a[9],x,f=1;
cout<<"Please enter an integer [0-10 only] : ";

[Code] ....

View 3 Replies View Related

C++ :: Program That Asks User For Numbers And Adds Odd Ones Doesn't Work

Nov 12, 2014

Title is self-explanatory.

Code:
#include <iostream>
using namespace std;
int main ( ) {
float number;
float sum;
float divi;
while(number != -1) {

[Code] .....

View 5 Replies View Related

Visual C++ :: Program Doesn't Accept Input Values True?

Nov 1, 2014

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.

View 2 Replies View Related

C++ :: Copy And Paste Function From Other Source Program Doesn't Wait For Input

Nov 27, 2013

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.

View 2 Replies View Related

C :: Program That Does UNIX Strings

Jun 4, 2014

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.

View 2 Replies View Related

C :: Program To Move Strings From 1 File To Another

Mar 5, 2013

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
}

[code]....

View 2 Replies View Related

C :: Making Program For Comparing Strings

Oct 16, 2013

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.

Code:

#include<stdio.h>
main()
{
char str1[] = "hello" ;
char str2[]= "hello" ;
int q;
q = xstrcmp(str1,str2);
printf("%d",q);
}

[code]....

View 5 Replies View Related

C++ :: Program To Read Several Strings From A File

Oct 11, 2013

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!

View 1 Replies View Related

C :: Program That Uses Tolower To Convert Strings Into Lowercase?

Oct 6, 2014

Any simple program that uses tolower to convert strings into lowercase? Or simply just the general syntax of tolower pls. Can find it in google.

View 5 Replies View Related

C :: Program To Match Strings From Input To Files Using Dfa

Sep 2, 2013

'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;
}

[code]....

View 3 Replies View Related

C++ :: Class Objects - Program Not Comparing Two Strings

Jun 20, 2013

I am having difficulty with class objects.

1. why my program won't actually compare the two strings.
2. why and where I am having a memory dump crash.

The following is my main.cpp, String.cpp, and the header file in that order.

#include <iostream>
using namespace std;
#include "GREEN_String.h"
void main () {
GREEN_StringStr1;
GREEN_StringStr2 ("AdrianGreen");

[Code] .....

View 5 Replies View Related

C :: Program That Provides Number Of Utilities For Strings - Keep Getting Segmentation Fault

Nov 22, 2014

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.

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"string_utils.h"

int strContains(const char * str,const char * subStr) {

[Code] ....

View 5 Replies View Related

Visual C++ :: Program That Take Strings From File And Push It Into Stack

Sep 29, 2013

How to write a programme that take strings from file and push it into the stack with number of each sting string before it and later clean the stack?

View 6 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 Append Strings To The Front Of Other Strings

Apr 7, 2013

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.

View 1 Replies View Related

C/C++ :: Print More Strings (the Strings May Contain Spaces)?

Feb 12, 2014

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.

View 2 Replies View Related

C :: Calendar Doesn't Work

Sep 24, 2013

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;

[Code]....

View 10 Replies View Related







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