siddhant3s 1,429 Practically a Posting Shark

>While you're at it, could you tell me why line 7 is invalid syntax?
Line 7 would have made sense if you had followed the proper syntax of the code tags:
[code=python] // the code which goes here will have // line numbers at left side

[/code]

Anyways, it turns out that you don't even know the proper syntax of if statement. If was not a bad thing if you were migrating from another language, but the fact is that you are starting programming for the first time.

Anyways, this is the proper syntax:

if <condition> :    #notice the colon
        //do something when
        //the condition is true

>I'd like to destroy whatever the source may be...
I would be glad to help you.

PS: Please follow a definitive tutorial or book to study python. The good part is: that there are enormous resources available for you to learn and most of them are free. You could start learning by the official Python Tutorial or perhaps "How to think Like a Computer Scientist" is also a valuable resource

scru commented: Doesn't the fact that he's starting programming for the first time make him more prone to make mistakes? -1
siddhant3s 1,429 Practically a Posting Shark

>Try this, it works
Why do you think I didn't gave him the code?
Anyways, here is my version.

#include <iostream>
#include <string>
#include <cctype>

std::string sentn_case(std::string s)
{
    size_t pos=0;
    //Capatalize the beigning of the string
    while (!isalpha(s[pos])) pos++;
    s[pos]=toupper(s[pos]);

    //Now find the period and split the string for next recursion
    pos=s.find(".");
    if (pos==std::string::npos)return s;

    while (!isalpha(s[pos])) pos++;
    return s.substr(0,pos)+sentn_case(s.substr(pos));
}
int main()
{
    std::string s=\
" and then a voice came over.\" hello. how are you. mister\"";
    std::cout<<sentn_case(s)<<std::endl;
}

The actual function is just 7 lines!
My solution may be less efficient (considering it uses recursion) but quite elegant.

@ArkM code: The output from your function was: And then a voice came over."hello. How are you. Mister"

iamthwee commented: And what are you doing here. Stop the spoon feeding! -4
siddhant3s 1,429 Practically a Posting Shark

Well, why are you not using std::strings?
I wrote a quick code with those. It is quite flexible:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string input="(98415)4554-215245";
    string area,exchange,extention;
    
    {//these are added to limit the scope of c_brace & hyphen
        size_t c_brace=input.find(")");//closing brace
        size_t hyphen=input.find("-");//the hyphen
        area=input.substr(  1, c_brace -1);
        exchange= input.substr( c_brace+1, hyphen-c_brace-1);
        extention= input.substr(hyphen+1,input.size()-hyphen);
    }
    
    cout<<area<<" "<<exchange<<" "<<extention;
    return 0;
}

(Oh my. Python has started to influence my Cplusplus)
I know few advocates can sue me to give away code, but I am here demonstrating the power of using STL (the computational code is just 5 lines)

iamthwee commented: Stop your spoon feeding :) -4
siddhant3s 1,429 Practically a Posting Shark

>>Why didn't the C++ standard also have the delete operator reset ptr to NULL?
First of all you are simply **NO ONE** to ask question like this. C++ standards have been made by the most proficient and experienced programmers of this language. If you think there should be a feature added doesn't means it should be added. A boon to you may be disaster to others. C++ standards have to keeps everyone in mind.

If you really feel that everyone is dumb and delete should really reset the pointer to null answer this:
Lets say I have the following code. Just check what would happened if delete would reset the pointer to zero:

int * p=new int;
int *q=p;// q points to same memory as p
delete p; //deleting p and setting it to zero
delete q;// Shit ! deleting pointer to null 0

Got that!!
So before opening the mouth and say "Mommy I want this candy" try to think how costly( or perhaps dangerous) that candy would be. Even if you can't think how costly it is, just trust your mother that she did a good thing by not buying you that candy.

mrnutty commented: A little harsh don't you think? And deleting a null pointer is allowed. And your code does not prove any point. -1