What does char bigstr[1000] = "" do?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #pragma warning(disable:4996, 4013)
#include <stdio.h>
#include <string.h>
int main(void)
{
	char bigstr[1000] = "", str[80];
	for (; ; )
	{
		printf("Enter a string: ");
		gets(str);
		if (!strcmp(str, "quit"))
			break;
		strcat(str, "\n");
		if (strlen(bigstr) + strlen(str) >= 1000)
			break;
		strcat(bigstr, str);
	}
	printf(bigstr);
	return 0;
}
Hi

Try this code and see the output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 #pragma warning(disable:4996, 4013)
#include<iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void)
{
	char bigstr[1000] = "", str[80];
	/*for (; ; )
	{
		printf("Enter a string: ");
		gets(str);
		if (!strcmp(str, "quit"))
			break;
		strcat(str, "\n");
		if (strlen(bigstr) + strlen(str) >= 1000)
			break;
		strcat(bigstr, str);
	}
	printf(bigstr);*/



cout<<bigstr<<endl<<str;

	return 0;
}


Got it?
Last edited on
This program does not work at all, dude.
This one runs on cpp.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>


using namespace std;

int main(void)
{
	char bigstr[1000] = "", str[80];
	/*for (; ; )
	{
		printf("Enter a string: ");
		gets(str);
		if (!strcmp(str, "quit"))
			break;
		strcat(str, "\n");
		if (strlen(bigstr) + strlen(str) >= 1000)
			break;
		strcat(bigstr, str);
	}
	printf(bigstr);*/



cout<<"bigstr: "<<bigstr<<endl<<"str: "<<str;

	return 0;
}


bigstr: 
str:  2��x 


got it now???
Last edited on
Topic archived. No new replies allowed.