-
strcmp help...
Hi, I've made a program to type out a bunch of text put into the char "sentence". one problem is that the text won't fit to the window. Is there possibly a way to set borderlines for the text? if not then i need some help with strcmp. i have it so it takes the array number, and type it out. and if the array number character is a period, then it makes a new line but i get an error message saying "cannot convert char to const char*" or something.
Code:
/****
Made by James, free for distribution.
****/
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char sentence[4000]= "This is a test. It should've made a new line there but it didn't. plz help!";
int x;
for(x=0; x<=3999; x++)
{
if(strcmp(sentence[x],".") cout<<"\n";
cout<<sentence[x];
}
cin.get();
return(0);
}
any ideas?
~Wiiplayer12
-
This is probably closer to what you are after:
Code:
if ( sentence[x] == '.') cout<<"\n";
-
Yes. You are using strcmp() and the first argument you are passing is not a string.
-
O, thank you so much dave!
if anyone wants the working code, here it is:
Code:
/****
Made by James, free for distribution.
****/
#include "stdafx.h"
#include <iostream>
#include "windows.h"
#include <cstring>
using namespace std;
int main()
{
char sentence[4000]= "This is a test.hello.hi.It workS!!!1!.~Wiiplayer12";
int x;
for(x=0; x<=3999; x++)
{
cout<<sentence[x];
Sleep(50);
if(sentence[x]=='.'){
cout<<"\n";
}
}
cin.get();
return(0);
}
~Wiiplayer12
-
Working? Even if it will scan the array outside your string bounds?