C++ :: Find A Name In Struct Of Names
Jul 6, 2014I cannot find the second name in the struct. First name comes out ok here is the code. I am reading from a file.
struct asma{
char name[200];
char birth[100];
[Code].....
I cannot find the second name in the struct. First name comes out ok here is the code. I am reading from a file.
struct asma{
char name[200];
char birth[100];
[Code].....
I'm trying to figure out the word frequency of a user inserted string. I've tried doing it via getline of the struct array and via the getline of the string word but neither either the former crashes or the latter just prints out the whole string.
Here is the latter.
#include "stdafx.h"
#include <iostream>
#include <string>
#define MAX_WORDS 200
using namespace std;
[Code] ....
How to handle the array of structs.
i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.
void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}
#include <stdio.h>
#define MAX_USERS 20
struct {
char ID[10];
char Name[40];
int Pos;
[Code] .....
I was attempting something weired with address to move data around when I discovered that the size of the array is not what I expected. I am passing this structure as &Users to a function that declares it as a void *, then I can deal with chunks of data (memmove) and not have to worry about index or things like that. However...sizeof is returning something I do not understand.
Im having trouble creating a struct within a struct node. the program suppose to hold students firstname, lastname, and gpa in a node therefore creating my linked list. Line 26 keeps saying that cannot convert parameter 2 from 'studentType to std::string
#include <iostream>
#include <string>
using namespace std;
struct studentType{
string firstname;
string lastname;
double gpa;
[code].....
"
#include <stdio.h>
struct datastructure {
char character;
};
void function(struct datastructure** ptr);
[Code] ....
These codes give these errors:
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
These errors are related to
"
*ptr->character='a';
printf("Ptr: %c",*ptr->character);
"
I want to access "character" data inside the structure "trial" by a pointer to pointer "ptr" inside function "function",but I couldn't find a way to do this.
I just read and have known for a while that classes are private (members and inheritance) by default and structs are public. But my question then comes what if.. a struct inheriting from a class or a class inheriting from a struct?
View 3 Replies View RelatedI am trying to create an array of file names such that when I want to open one of the files, who's name is given in the array, I can call that element of the array. My code for making the array is the following,
Code:
char file_name[40];
char *file_locations[N]; // array of N names (*)
for(ii=0; ii<=N-1; ii++){ // printing the names of all the files P1_8mag_1.txt - P1_8mag_N.txt
sprintf(file_name, "P1_8mag_%i.txt", ii+1);
[Code]....
The problem with this is that in the first step: all elements of the array "file_locations" are the name of the last file in the loop (in this case "P1_8mag_N.txt")What is wrong with this?
I have an assignment that needs to display the names of customers to be served according to a sequence. coding to display the names accordingly?
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXIMUM 20
void create();
[Code].....
This is my output. I have trouble displaying the names of the customers as it outputs null when I try to display my position in queue.
char *name[50]
How to accept 50 names using above definition...
All I wanted to do is to sort the car names according to their mileage. And display the output with their car names. This is what I've made
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int j;
class car
[Code].....
I need to take 5 car details and sort them according to their Mileage..
The following code shows bad memory access error (segmentation fault) when I run it. It does this right after it asks for name and the user has entered it.
#include <iostream>
#include <sstream>
using namespace std;
struct Name {
string first;
string last;
[Code] ....
I have .db3 file, and he has 14 tables,and every table has certain number of columns. Example i have table called "BASIC_INFO" and that table has columns "First Name", "Last Name" and "Age".
How can i get name of table and name of every column,so if i some day add column "Male" i get name of this column too. I need first to calculate number of columns,put that in some integer, and then for example create string array which will contain : array[0] = "First Name" ,array[1] = "Last Name"...
SQLiteConnection myConn = new SQLiteConnection("Data Source=" + DB3Path + ";Version=3;New=False;Compress=True;");
//string query = "Select * From " + DB3Path + ".INFORMATION_SCHEMA.COLUMNS";
string query = "Select * From BASIC_INFO.INFORMATION_SCHEMA.COLUMNS;";
SQLiteCommand sqCommand = new SQLiteCommand(query);
[Code] ....
I tried this too:
string query = "select * from INFORMATION_SCHEMA.COLUMNS"
+ "where TABLE_Name='BASIC_INFO'"
+ "order by ORDINAL_POSITION;";
string query = "SELECT TOP 0 * FROM BASIC_INFO";
I have encountered errors when trying to display the customers' names in a priority queue.
#include <stdio.h>
#include <stdlib.h>
#define MAXIMUM 20
void create();
void priority_insert(int data);
void check(int data);
[code]....
I have gotten the following output:
Peter
Peter
<Null>
How do I correct my coding to display like below:
John
Peter
So I been asked to write a program that does the following:
Write a program that allows the user to enter a series of 10 names from the keyboard and then sorts and prints the names in alphabetical order. Use a series of functions:
1) Input the data
2) Sort the data (use a bubble sort)
3) Print the data
After this is done, allow the user to enter a name from the keyboard and determine if the name appears in the list. Use a function to accomplish the search. The name to be searched for should be input within main and sent to the function as an argument.
4) Search the data (use a binary search of type bool)"
this is whats I wrote so far and its giving me error with the sorting and the searching, I need to fix it and I cannot figure out how?!.
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
void bubbleSort(string[], int);
int main()
[Code]....
I cannot manage to get the code for sorting the names in alphabetical order.
#include<stdio.h>
#include<string.h>
typedef struct{
char criminalName[10];
char criminalCase[20];
[code]....
The point of this code is to get 15 names and then hash them. After one name is entered I get a segmentation Fault and the program crashes.
Code:
//driver file
#include <iostream>
#include <vector>
#include <string>
using namespace std;
[Code] ....
I am doing a homework assignment. I do not want the complete answer, just a hint. I have to load a file of names into an array, display the names, then sort the names alphabetically, display them again, then list how many names start with certain letters. I have everything done but how to display how many names start with a certain letter.
Here are the names:
Collins, Bill Smith, Bart
Allen, Jim
Griffin, Jim
Stamey, Marty
Rose, Geri
...........
And here is the code I have so far.
Code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <algorithm>
[Code] ....
ive done a code for taxi's that arrive and depart, but i was wondering how i can use names of taxis as registration instead of numbers?
View 1 Replies View RelatedI'm trying to read a C code, but there are functions including CLASS word at the titles of functions. Is it a correct implementation?
For example: double CLASS getreal (int type)
What is the meaning of CLASS in titles of functions in C? I could not find such an usage in my C book?
I haven't tried to run my program yet, but maybe I will save some trouble if I ask this question first.I am using MC PIC16F690, and I could make a pin high or low by writing RCx = 1 or 0, where x is the pin in the C port. However, I want to use the counter variable from a for() loop as the pin number. Will RC(variablename) = 1 work, or is there another syntax?
View 2 Replies View RelatedI want to print different color names for "nb " times . I get the number " nb " from the user or from text file . if " nb = 3 " then I want to print any 3 different color names which means that I may print ( red , green , blue ) for example . and if " nb=5 " then I have to print any five different color names ( pink , blue , black , red ,white ) fore example .
Note : " nb " may be a large number ( 17 for example ). How can I do this ?
For my project I have to sort 5 numbers and 5 names using a template bubble sort. I have one header for the numbers, and one for the names. This is what I have so far for my testing page:
#include "Floatheader.h"
#include "Nameheader.h"
#include <string>
int main ()
myFloat obj1;
myFloat obj2( 2.2, 5.1);
[Code] .....
I have to create a template to look like this: template<>....with a class inside the arrows. Then, I have to use bubble sort to sort the 5 names and number objects I have created. Sorting the names and numbers and also using templates?
i wonder how does any os address file having spaces in their names.Even cmd.exe in windows can't access such file but windows explorer can. How is it so?
View 4 Replies View RelatedWe need a program that takes three names ( first middle last ) and print it each one at a different line...
View 5 Replies View RelatedI am at a lost of how to sort names in alphabetical order after having the user input them into a linked list. I manage to create a program that did have the person input names into the linked list and when it is printed it displays the names in the order of how the user inputted the names.
#include <cstdlib>
#include <iostream>
using namespace std;
#include <string>
class NodeType {
public:
string NodeValue;
[Code] .....