Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone help me to solve this for me? I solved the first Q.. but stuck in second 1) Write a program that will ask the user for world wide web domain (eg. "google‌.‌com") and concatenates it with "https‌://‌www.". At the end resulting string has to be stored in single array. HINT 1 Define array containing prefix with larger size: char address[100] = "https://www.";. HINT 2 Use strcat() to join both arrays. 2) Display ASCII code of each address character in separate lines. Use a for loop with strlen() as stop condition to detect end of the string. 3) Modify the for loop to display whole array, even after the NULL termination. What is contained within the array after the NULL sign.

What I have tried:

C++
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int main()
{
    char web[100];
    char site[100] = "http://www.";
    cout << "name a world wide web site" << endl;
    cin >> web;
    strcat(site, web);
    cout << site << endl;
 

    return 0;
}
Posted
Updated 9-Apr-20 19:27pm
v2
Comments
Patrice T 9-Apr-20 23:48pm    
Where are you stick exactly, what did you tried ?
Member 14797679 11-Apr-20 17:37pm    
i tried second question but failed

1 solution

Hints:
  • ASCII code of ith item of the array a is just a[i] (to show its numeric value: cout << (int) << a[i];).
  • First loop range: 0, 1, .., strlen(address)-1.
  • Second loop range: 0, 1, .., sizeof(address)-1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900