Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sample input 11/07/20
sample output 11 07 20

What I have tried:

C++
#include<stdio.h>
int main(){
	char date[11];
	int dd,mm,yy;
	
	
	
	printf("%d %d %d",dd,mm,yy);

return 0;
}
Posted
Updated 3-Oct-20 3:53am
v2
Comments
Patrice T 3-Oct-20 9:18am    
And ?
you have a question ?

Two different ones:

(1) C style
C
nclude <stdio.h>

void slash_to_blank(char * s)
{
  for (; *s; ++s)
  {
    *s = (*s == '/') ? ' ' : *s;
  }
}


int main()
{
  char d[] = "11/07/20";

  slash_to_blank(d);

  printf("%s\n", d);

  return 0;
}



(2) C++ style
C++
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{ 
  char d[]{"11/07/20"};
  
  replace_if( begin(d), end(d), [](char c){return c=='/';}, ' ');
  
  cout << d << endl;
}
 
Share this answer
 
Comments
Richard MacCutchan 3-Oct-20 10:09am    
Nice.
 
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