-
help please!!!!!
i am new to c++ and this is my second program for class...keep getting the error, warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime. can someone help me out please, here is my code:
Code:
#include <stdio.h>
#include <cstdlib>
#include <iostream>
using namespace std;
// Input first and last name, grade, ande print out their name and lettergrade
int main(int argc , char *argv)
{
string name, grade, A, B, C, D, F;
cout << "Please insert your first and last name:\n";
cin >> name;
cout << "Please insert your numeric grade:\n";
cin >> grade;
name = name;
grade = grade;
if ("90" <= grade &&
grade <="100") A;
if ("80" <= grade &&
grade <= "89") B;
if ("70" <= grade &&
grade <= "79") C;
if ("60" <= grade &&
grade <= "69") D;
if (grade <= "59") F;
printf("Hello name\n", name);
printf("You Made grade\n", grade);
}
-
printf only accepts c-style string, that is const char * typed strings. std::string has a method, c_str that will provide a c-style version of the string.
Code:
printf("Hello name\n", name.c_str());
-
And what would '...' be?
Don't mix C and C++ like that. Use cout instead of printf.
-
thanks for the help i fixed it