#How To find the first name and last name with initials while following these constraints.

51 messages · Page 1 of 1 (latest)

uneven abyssBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

marble compass
#

again to reclarify I can't use any functions or vectors or like .find. only the approved functions i listed above. I also need the first and last name stored in one variable. i can use two variables for the first and last initial.

#

current code i have. I am struggling to find a way to get the first and last name initials while following the constraints

graceful geode
#

we're not going to write it for you

#

or ask a more specific question

marble compass
graceful geode
#

so, try and then show us

marble compass
graceful geode
#

;compile

clear stormBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

graceful geode
#

look at the list of functions you say you're allowed to use

#

be sure you understand what each one does

#

;compile

clear stormBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

cloud pythonBOT
#
How to Format Code on Discord

• type three "backticks" (not quotes/apostrophes, on QWERTY layout, left of 1-key)
• on the same line, type the file extension for that language (c or cpp)
• enter your code on a new line and put another three backticks at the end

Example Input

```cpp
int main() {
    return 0;
}
```

Example Output
int main() {
    return 0;
} ```
marble compass
#

#include <iostream>
#include <cmath>
#include <string>

#include <iostream>


using namespace std;
int main()
{
    string name; 
    char firstInitial; 

    cout << "Enter your first and last name: ";

    getline(cin, name);


    cout << "Hello " << name; 

    firstInitial = name.at(0);  
return 0; 

} ```
#

;compile

clear stormBOT
#
Critical error:

You must attach a code-block containing code to your message or quote a message that has one.

clear stormBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

clear stormBOT
#
Critical error:

You must attach a code-block containing code to your message or reply to a message that has one.

marble compass
#

ugh

clear stormBOT
#
Compiler Output
<source>: In function 'int main()':
<source>:3:5: error: 'string' was not declared in this scope
    3 |     string name;
      |     ^~~~~~
<source>:6:5: error: 'cin' was not declared in this scope
    6 |     cin.get();
      |     ^~~
<source>:7:5: error: 'cout' was not declared in this scope
    7 |     cout << "Enter your first and last name: ";
      |     ^~~~
<source>:9:18: error: 'name' was not declared in this scope
    9 |     getline(cin, name);
      |                  ^~~~
<source>:9:5: error: 'getline' was not declared in this scope
    9 |     getline(cin, name);
      |     ^~~~~~~
Build failed
clear stormBOT
#
Compiler Output
<source>: In function 'int main()':
<source>:3:5: error: 'string' was not declared in this scope
    3 |     string name;
      |     ^~~~~~
<source>:6:5: error: 'cin' was not declared in this scope
    6 |     cin.get();
      |     ^~~
<source>:7:5: error: 'cout' was not declared in this scope
    7 |     cout << "Enter your first and last name: ";
      |     ^~~~
<source>:9:18: error: 'name' was not declared in this scope
    9 |     getline(cin, name);
      |                  ^~~~
<source>:9:5: error: 'getline' was not declared in this scope
    9 |     getline(cin, name);
      |     ^~~~~~~
Build failed
clear stormBOT
#
Compiler Output
<source>: In function 'int main()':
<source>:3:5: error: 'string' was not declared in this scope
    3 |     string name;
      |     ^~~~~~
<source>:6:5: error: 'cout' was not declared in this scope
    6 |     cout << "Enter your first and last name: ";
      |     ^~~~
<source>:8:13: error: 'cin' was not declared in this scope
    8 |     getline(cin, name);
      |             ^~~
<source>:8:18: error: 'name' was not declared in this scope
    8 |     getline(cin, name);
      |                  ^~~~
<source>:8:5: error: 'getline' was not declared in this scope
    8 |     getline(cin, name);
      |     ^~~~~~~
Build failed
graceful geode
#

you didn't put all your code in the block

#

you can see as much because of the colors

marble compass
graceful geode
graceful geode
clear stormBOT
#
Program Output
Enter your first and last name:
Compiler Output
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 1) >= this->size() (which is 0)
marble compass
#

sigh

#

what else is missing now in there

clear stormBOT
#
Program Output
Enter your first and last name:
Compiler Output
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 1) >= this->size() (which is 0)
marble compass
#

I think its working but because i am having the user input a value its not running correctly all the way?

graceful geode
#

indexes start at zero

#

not one

marble compass
#

oh i left that in there when i was experimenting

clear stormBOT
#
Program Output
Enter your first and last name:
Compiler Output
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)
marble compass
#

ok well its giving the same output even after I changed that

#

Im just gonna make a new post to reduce this clutter

#

!solved