|  | 
|  | 
| back to board | Compilation error  #include <iostream.h>
 #include <stdio.h>
 
 using namespace std;
 
 int main()
 {
 char * s;
 cin >> s;
 
 int a[200] = {5};
 for (int i = 0; i < strlen(s); i++)
 a[i+1] = (s[i] - 'a');
 int n = strlen(s);
 
 for (int i = n; i >= 1; i--)
 {
 a[i] -= a[i-1];
 if (a[i] < 0) a[i] += 26;
 }
 
 for (int i = 1; i <= n; i++)
 cout << (char)(a[i]+'a');
 
 }
 
 why compilation error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Re: Compilation error Your solution was compiled with the following errors:
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(4): error: name must be a namespace
 name
 using namespace std;
 ^
 
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(9): warning #592: variable "s" is used
 before its value is set
 cin >> s;
 ^
 
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(12): error: identifier "strlen" is
 undefined
 for (int i = 0; i < strlen(s); i++)
 ^
 
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(14): error: identifier "strlen" is
 undefined
 int n = strlen(s);
 ^
 
 ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(25): warning #1: last line of file
 ends without a newline
 }
 ^
 
 compilation aborted for ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b (code 2)
Re: Compilation error Your compiling code--
 #include <iostream.h>
 #include <stdio.h>
 #include <string.h>
 
 
 int main()
 {
 char * s;
 cin >> s;
 
 int a[200] = {5};
 for (int i = 0; i < strlen(s); i++)
 a[i+1] = (s[i] - 'a');
 int n = strlen(s);
 
 for (int i = n; i >= 1; i--)
 {
 a[i] -= a[i-1];
 if (a[i] < 0) a[i] += 26;
 }
 
 for (int i = 1; i <= n; i++)
 cout << (char)(a[i]+'a');
 
 };
Re: Compilation error and dont forget std namespace. | 
 | 
|