fork download
  1. // here is my code
  2. #include <iostream>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <fstream>
  6. #include <cstring>
  7. #define MAX 15
  8. using namespace std;
  9. char fourdigOfnum(char *s1,char *s2) {
  10. int i=0;
  11. while(i<4)
  12. {
  13. s1[i]=s2[i];
  14. ++i;
  15. }
  16. s1[i]='\0';
  17. }
  18. int main() {
  19. char num_dig[4],simCard[MAX];
  20. char mobile_num[MAX];
  21. ofstream file;
  22. file.open("mobile.txt",ios::out);
  23. cout<<"Enter a Mobile-Number : "; cin>>mobile_num;
  24. if(mobile_num[0]==0||strlen(mobile_num)==11)
  25. {
  26. //num_dig=fourdigOfnum(str_num);
  27. fourdigOfnum(num_dig,mobile_num);
  28. if(num_dig[strlen(num_dig-1)]==0)
  29. {
  30. strncpy(simCard,"Jazz",sizeof(simCard));
  31. }
  32. else if(num_dig[strlen(num_dig-1)]==1)
  33. {
  34. strncpy(simCard,"Zong",sizeof(simCard));
  35. }
  36. else if(num_dig[strlen(num_dig-1)]==2)
  37. {
  38. strncpy(simCard,"Warid",sizeof(simCard));
  39. }
  40. else if(num_dig[strlen(num_dig-1)]==3)
  41. {
  42. strncpy(simCard,"Ufone",sizeof(simCard));
  43. }
  44. else if(num_dig[strlen(num_dig-1)]==4)
  45. {
  46. strncpy(simCard,"Telenor",sizeof(simCard));
  47. }
  48. } else {
  49. cout<<"You entered a Invalid number "<<endl;
  50. }
  51. if(file.fail())
  52. {
  53. cout<<"Sorry File is failed to open "<<endl;
  54. } else {
  55. file<<"Your Mobile-Number is "<<mobile_num<<endl;
  56. file<<"This is a "<<simCard<<" number "<<endl;
  57. }
  58. file.close();
  59. system("pause");
  60. return 0;
  61. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:59:23: error: 'system' was not declared in this scope
         system("pause");
                       ^
stdout
Standard output is empty