C/C++ :: Better Way To Parse And Format Phone Numbers?

Sep 3, 2014

I'm a student. I've complete an exercise where the goal is to parse some user input to output phone numbers using EXACTLY this style (not including the quotes): "1-888-8888".

Some rules that I've set for my parser are,

1) the phone number can be mixed in with other text, e.g. "My number is 38888888" or "1asdfk8888888" and

2) the first number found must be a valid calling code (1-9).

I wanted the parser to be flexible. Is this nesting too deep?

std::string format_phone_num(std::string &s) {
std::string formatted_num = "";
bool call_code_found = false;
short num_count = 0;
for (unsigned int i = 0; i < s.length(); i++)

[code].....

View 4 Replies


ADVERTISEMENT

C# :: Emails And Phone Numbers - Output List Name Not Text?

Sep 11, 2014

Trying to output a .txt file of names emails and phone numbers, but this only outputs the list name: Email.PersonEntry.

private void button1_Click(object sender, EventArgs e) {
DialogResult result;
string fileName;
//Find and Open File

[Code] ....

View 6 Replies View Related

C :: Write A Main Function That Parses A Text Document And Prints Out All Of Phone Numbers Found

Apr 21, 2014

You should implement the following function:

int is_phone_number(char* string)
This function will take in a string and return 1 if it looks like a phone number 0 otherwise. A phone number takes the form (xxx)-xxx-xxxx where the xs are digits 0-9. So for example (123)-456-7890 is a valid phone number while 123 456-7890 is not.

You should also write a main function that parses a text document and prints out all of the phone numbers found. Hint, look up the strtok function.

Sample input:
Please call me at (123)-456-789 sometime tonight.

Sample output:
Phone number : (123)-456-7890

View 5 Replies View Related

C :: Not Getting Actual Output While Displaying Hex Numbers In Decimal Format

Apr 26, 2013

I need to display 0-15 hex numbers[0X00-0x0F] in decimal value...& I'm getting the output but it's not exactly what it should be,below is my code.. [This not the complete code,but main part where the changes are done]

Actual output i should get is for 1v it should generate 0001,for 2v it should generate 0010 and simultaneously till [15v-1111]... But what i'm getting is exactly different to this for eg for 7v,8v&9v the bits generated are 1101,1011,1011 respectively...

[URL] ....

Code:
sbit V1 = P2^0;
sbit V2 = P2^2;
sbit V3 = P2^4;
sbit V4 = P2^6;
#define DAC_table V1,V2,V3,V4

#include <stdio.h>
#include <string.h>
idata unsigned int ptr2tbl ;

[Code] .....

View 2 Replies View Related

C/C++ :: Adding Two Phone Agendas Together

Apr 4, 2015

I got this problem where I need to create a phone agenda where every name coresponds to a phone number. I decided to create this as a 2 dimensional string array.

But what I do not know how to do is:

I need to create 2 agendas(created in main(ag1 and ag2)) and then add them together to create one big agenda that contains the members of ag1 and ag2.

#include "stdafx.h"
using namespace std;
class Agenda{
string date[20][20];
public:
Agenda();
void afisare();

[Code] ....

View 1 Replies View Related

C :: Phone Book Saving To File And Retrieving

Jul 14, 2013

I am supposed to make this phone book save to a file and then be able to retrieve it.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Phonebook_Contacts
{
char FirstName[20];
char LastName[20];
char PhoneNumber[20];
} phone;
}

[code]....

View 4 Replies View Related

C :: User Can Input Phone Number In Any Of Formats

Jun 18, 2013

I'm having a bit issue with ispunct in my function. The user can input a phone number in any of the formats below:

4147778888
(414)7778888
(414)777-8888

The program will only print out:

41447778888

What I am trying to do is accept any integer and parentheses. If the user inputs anything else, the program will display an error message. Right now, parentheses displays an error which is obvious but I'm wondering if there is a way I can allow a parentheses to be entered but not any other symbol. ex: . , : ; " '

Code:
void getPhoneNum(){
// Local Declarations
char string[14];
char* tokPtr;

[Code] ....

View 6 Replies View Related

C Sharp :: How To Remove Ads And Add More Space (Windows Phone)

Aug 18, 2013

I have made a new Windows Phone App and I would like there to be two versions: one without ads (79p) and one with ads (free). I have sorted out everything expect one issue. I collapse the advert if the app is in the full version but the rest of the page stays the same. How do I move the 'content panel' after the advert is collapsed?

View 1 Replies View Related

C :: Generate Words From User Input (Phone Number)

Aug 13, 2013

The basic idea of this exercise is to generate words from a user-input, seven-digit number(a phone number). The code runs, but for some reason, I can't get it to print the numbers into the file.

Code:
/*Write a program that will generate a word based on a randomly generated, seven-digit number. there should be 2187 possible words. Avoid "phone numbers" that begin with 0 or 1*/

#include<stdio.h>
#define PHONE 7
void wordGenerator(int number[]);
void wordGenerator(int number[]) {
//loop counters for each digit in the number

[Code] ....

View 3 Replies View Related

C# :: Windows Phone 8.1 Auto Lock Screen Code

Mar 6, 2015

Auto lock screen coding for windows phone 8.1.

View 2 Replies View Related

C# :: Changing Web-browser Emulation Mode (Windows Phone)?

Nov 4, 2014

I was looking around on the internet and i noticed you could change internet explorer's emulation mode from Desktop to Windows Phone, i was wondering can the same thing be achieved in the C# webbrowser as i know it heavily rely's on IE. I know you can change the standards on the browser through the IE versions but is changing it to Windows Phone Brwoser possible, if so how can i change it?

View 5 Replies View Related

C/C++ :: Read Name / Phone Number And Address From A File - How To Use Fscanf

Nov 28, 2014

I am trying to read the name, phone number and address from a file ... Here is the code but it doesn't work and i don't know where is the problem ...

#include <stdio.h>
#include <stdlib.h>
struct PhoneBook{
        char name[50];
        int phoneNumber;
        char address[50];

[Code] ....

And here is the contents of the file:
jack 01014 jgd

Moh 02925 Tyeu

When I run it on dev c++, a message appear saying that the prog has stopped working and no output appears. I want to put the name in user[n].name, the phone number in user[n].phoneNumber and the address in user[n].address

View 1 Replies View Related

C :: How To Make Array Of Structures For Basic Contact List In A Phone

Oct 17, 2013

So for class I have to make an array of structures for a basic contact list in a phone.

I understand the bones of the program and how to go about doing most of it but as far as arrays of structures go I am blind.
Code:

struct phone
{
char FirstName[16];
char LastName[16];
int Number[11];
};
struct phone numbers[friends]; //friends is a variable assigned by the user What I am a bit confused about is say the user enters 30 as how many friends they have. How would I assign a value to the 3rd struct for LastName?

View 3 Replies View Related

C++ :: Read Phone Number Into Array And Can't Use String Data Type

Jan 13, 2013

I have an assignment where I need to read in a phone number into any array and I can't use the string data type. Assuming I need to use the getline function, how do I do this? I'm guessing it's with the cstring or .c_str() functions? I don't know.

View 4 Replies View Related

C :: Write A Program That Converts Alphanumeric Phone Number Into Numeric Form

Mar 6, 2015

i m learning c programming and i m stuck with this program for some reason.Write a program that converts alphanumeric phone number into numeric form:

O/P:
Enter phone number: CALLAT 2255288
here is the code i have written:
/** compilers shows no error **/
and O/P I get is
Enter phone number: CALLAT
/**blank space***/

Code:

#include<stdio.h>
int main(void)
{
char ch;
printf("Enter phone number:");
ch=getchar();
}

[code]....

View 4 Replies View Related

C++ :: How To Parse EML File

Aug 28, 2014

I am doing a project processing emails in EML format. I searched for a library doing eml file parsing and got no hits. I really dont want to code the parser myself. I just want to get the project done with minimize cost. Which library should I use?

View 4 Replies View Related

C :: Parse Error / What Value Does Get Assigned

Dec 10, 2013

I get the following parsing error for the code

Code:

#include <stdio.h>

int main()
{
int i=3,4;
printf("%d",i);
return 0;
}

what is wrong with the code? I have put initialize value as 3,4 just to understand what value does i gets assigned.

View 5 Replies View Related

C++ :: Parse Value From Text File?

May 16, 2014

Suppose i have a text file with ":" as delimiter, how to i find the average value of each column? For e.g. First column will be (3+2+5)/3 and second column will be (61+87)/2 for the third column.

Sample text file
================
3:290:61:100:
2:50:
5:346:87:

I have tried using getline in while loop, but it seemed more complicated because i think it requires much more than that.

View 2 Replies View Related

C/C++ :: How To Parse CSV Data With TinyXML 2

Mar 22, 2014

I am using TinyXML 2 for the data of my RPG game, I am almost done with the tilemap parsing system, but I just couldn't figure out how to extract csv data that I have in my XML file, like this:

<data encoding="csv">
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

[code]....

What I want to do is to extract this data using TinyXML 2 and to put the data into a 2D vector...how can I do that?

View 9 Replies View Related

C :: Array Program - Parse Error Before INT

Sep 18, 2013

this program is just to give the size and value of the array by the user.

Code:
#include <stdio.h>
main( ) {
int size ;
scanf ( "%d", &size ) ;
int arr[size] ;
for ( i = 1 ; i <= size ; i++ ) {
scanf ( "%d", arr[i] ) ;
printf ( "%d", arr[i] ) ;
}

error : Code:
C:UsersDocumentsprog est.c:7: parse error before `int'

View 7 Replies View Related

C :: Using A Pointer To Parse Multidimensional Array

Feb 27, 2015

I have a 3-dimensional matrix(3,3,3) and want to write it to a file. I have the code for parsing it in a compatible for matlab format. But at this point i want to use a pointer to do the same thing.

Code:

#include <stdio.h>
#include <stdlib.h>
int main() {
const int dimx = 3, dimy = 3;
int i, j;
unsigned char a[3][3][3] = {

[Code]...

If it is a 1-dimensional array i can understand the logic.

Code:

int val[7] = { 11, 22, 33, 44, 55, 66, 77 } ;
int *p;
p = val[0];
for ( int i = 0 ; i <= 6 ; i++ )

[Code]...

View 3 Replies View Related

C++ :: Parse A Text File That Contains Information

Jul 31, 2014

I am trying to parse a text file that contains information and i cant seem to get started. For example, the text file looks like this:

idx=929392, pl= 12, name= someperson
age=19
state=ma
status=n/a

idx=929393, pl= 12, name= someperson2
age=20
state=ma
status=n/a

idx=929394, pl= 12, name= someperson3
age=21
state=ma
status=n/a

I want to parse the name and age into another text file like this format:

someperson 19
someperson 20
someperson 21

possibly include other attributes next to the age like idx?

View 3 Replies View Related

C++ :: Parse And Edit A Text File?

Nov 14, 2014

I have this project for school where I basically need to write a program that will take any text file and convert it into html code.

string line;
int lineCount = 0;
while (!inFile.eof()) {
getline(inFile, line);
cout << line << endl;
lineCount++;
}
cout << lineCount - 1 << " lines of text read in this file." << endl;

I have this block of code to print each line of the text file into the terminal window and count the number of lines printed. But I don't know how to make it change a single character or set of characters to something else. For example, if a line of text begins with the number "1", I want to be able to change it to "<h1>".

View 2 Replies View Related

C++ :: Using Getline To Parse From A Text File?

Nov 23, 2014

I'm trying to make a program where it reads a text file which contains "blocks" of questions like:

Type: multiple_choice
Question
Num_options: number of options
a) option1
b) option2
c) option3
d) option4
Letter of answer

and

Type: short_answer
Question
Answer text

what I'm trying to do is use parse those blocks and have it get handled by the classes, MultipleChoice and ShortAnswer.

I'm planning on using getline as a virtual function and have an if statement like
"if (string == "multiple choice)
** then get it handled by the MultipleChoice class "

View 10 Replies View Related

C++ :: Parse The Root Directory Of FAT32?

Dec 27, 2013

I'm trying to parse the root directory of FAT32 in order to get a dir list in the root folder.

So I need to go over all the directory entries in the root directory and parse them.

My problem is that I don't know when to stop the iteration - How to get the size of the root directory?

I noticed that there is a byte in the boot sector - the number of the entries in the root - but in FAT32 the value is always 0, So how can i get the size of the directory?

View 1 Replies View Related

C/C++ :: Parse Telephone Data File?

Oct 18, 2014

Write a program that reads the telephone.dat file and displays its contents on the console. The program should allow the user to add new entries to the file.

I have saved the file into a resource file within visual studio and I am trying to run the code to where the file will be shown when I run the program. I know that the program is running and the file is there because if i misspell the filename it will give me the error message. I don't know how to make the contents of the file display.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string input;
fstream dataFile;

[code]...

View 14 Replies View Related







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